;

# Python Program to Print Even Numbers from 1 to Nth Number or Between a Specific Range

###### Tutorialsrack 22/04/2020 Python

In this Python program, we will learn how to print even numbers from 1 to nth number or between a given specific Range.

Here are some examples of the program to print even numbers from 1 to nth number or between a given specific Range.

### Program 1: Using for Loop

Program 1: Using for Loop

``````# Python Program to Print Even Numbers from 1 to Nth Number

# To Take Input from User
maxNum = int(input("Enter the Maximum Value : "))

for number in range(1, maxNum+1):
if(number % 2 == 0):
print("{0}".format(number))
``````
##### Output

Enter the Maximum Value : 10

Even Number Between 1 to 10:

2

4

6

8

10

### Program 2: Using for Loop Without Using if Statement

Program 2: Using for Loop Without Using if Statement

``````# Python Program to Print Even Numbers from 1 to Nth Number

# To Take Input from User
maxNum = int(input("Enter the Maximum Value : "))
print("Even Number Between 1 to {0}: ".format(maxNum))
for number in range(2, maxNum+1, 2):
print("{0}".format(number))
``````
##### Output

Enter the Maximum Value : 10

Even Number Between 1 to 10:

2

4

6

8

10

### Program 3: Using While Loop

Program 3: Using While Loop

``````# Python Program to Print Even Numbers from 1 to Nth Number

# To Take Input from User
maxNum = int(input("Enter the Maximum Value : "))
print("Even Number Between 1 to {0}: ".format(maxNum))
number = 1

while number <= maxNum:
if(number % 2 == 0):
print("{0}".format(number))
number = number + 1
``````
##### Output

Enter the Maximum Value : 10

Even Number Between 1 to 10:

2

4

6

8

10

### Program 4: Between a Specific Range

Program 4: Between a Specific Range

``````# Python Program to Print Even Numbers Within a Specific Range

minNum = int(input("Enter the Minimum Value: "))
maxNum = int(input("Enter the Maximum Value: "))
print("Even Number Between {0} to {1}".format(minNum,maxNum))

for number in range(minNum, maxNum+1):
if(number % 2 == 0):
print("{0}".format(number))
``````
##### Output

Enter the Minimum Value: 5

Enter the Maximum Value: 15

Even Number Between 5 to 15

6

8

10

12

14