Computer Science, asked by imanmukherjee04, 3 months ago


Display all the even numbers in a range​

Answers

Answered by Anonymous
1

Answer:

Approach: Total numbers in the range will be (R – L + 1) i.e. N.

  • If N is even then the count of both odd and even numbers will be N/2.
  • If N is odd, If L or R is odd, then the count of odd number will be N/2 + 1 and even numbers = N – countofOdd. Else, count of odd numbers will be N/2 and even numbers = N – countofOdd.
Answered by umakantjondhale18
0

Answer:

Python program to print all even numbers in a range

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

Example:

Input: start = 4, end = 15

Output: 4, 6, 8, 10, 12, 14

Input: start = 8, end = 11

Output: 8, 10

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

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 Even Numbers in given range

start, end = 4, 19

# iterating each number in list

for num in range(start, end + 1)

Similar questions