Python Program to Print Even Numbers In A Given Range

This program prints all even numbers in a given range by user in Python language.

In this Python program, we first read min_value and max_value from user. Then we print all even numbers using for loop and if statement.

Python Source Code: Odd Numbers


# Print Even numbers in range

min_value = int(input("Enter minimun of range: "))
max_value = int(input("Enter maximun of range: "))

print("\nEven numbers from %d to %d are: " % (min_value, max_value))
for i in range(min_value, max_value+1):
    if(i%2==0):
        print(i, end=" ")

Output

Enter minimun of range: 23
Enter maximun of range: 46

Even numbers from 23 to 46 are: 
24 26 28 30 32 34 36 38 40 42 44 46