Computer Science, asked by CEOEkanshNimbalkar, 1 year ago

100 POINTS
Write a program in python to print number of even number and number of odd number between 1 to 50.​

Answers

Answered by Anonymous
1

\huge\bf{Answer:-}

• l = list [ range [ 1 , 5 1 ] ]

• a = int [ Input [ 1 ]

• count = [ - 1 ]

• [ I = l ] :

• [ I % 5 = 0 ] :

• count = count + 1

• Print = [ count ]

Answered by nilesh102
3

hi mate,

Answer :

Python program to print all odd numbers in a range

Given starting and end points, write a Python program to print all odd numbers in that given range.

Example:

  • Input: start = 4, end = 15
  • Output: 5, 7, 9, 11, 13, 15

  • Input: start = 3, end = 11
  • Output: 3, 5, 7, 9, 11

  • Define start and end limit of range. Iterate from start till the range in the list using for loop and check if num % 2 != 0. If the condition satisfies, then only print the number.

# Python program to print odd Numbers in given range

start, end = 4, 19

# iterating each number in list

for num in range(start, end + 1):

# checking condition

if num % 2 != 0:

print(num, end = " ")

  • Output:

5 7 9 11 13 15 17 19

Example #1: Print all odd numbers from given list using for loop

Example #2: Taking range limit from user input

# Python program to print Even Numbers in given range

start = int(input("Enter the start of range: "))

end = int(input("Enter the end of range: "))

# iterating each number in list

for num in range(start, end + 1):

# checking condition

if num % 2 != 0:

print(num, end = " ")

  • Output:

  • Enter the start of range: 3
  • Enter the end of range: 11

Enter the end of range: 11 3 5 7 9 11

Example #3: Taking range limit from user input

# Python program to print Even Numbers in given range

start = int(input("Enter the start of range: "))

end = int(input("Enter the end of range: "))

#create a list that contains only Even numbers in given range

even_list = range(start, end + 1)[start%2::2]

for num in even_list:

print(num, end = " ")

  • Output:

  • Enter the start of range: 3
  • Enter the end of range: 11

Enter the end of range: 11 3 5 7 9 11

i hope it helps you.

Similar questions