# Python Program to Print Even Numbers from 1 to N

18-Oct-2022

.

Hi Dev,

This tutorial shows you Python Program to Print Even Numbers from 1 to N. We will look at example of Python program to print all even and odd numbers. it's simple example of Python Check Number Odd or Even. This article goes in detailed on Python Program to Check if a Number is Odd or Even . So, let's follow few step to create example of Print the odd and even numbers using While Loop in python.

Algorithm to print even and odd numbers from 1 to N

so let's see following examples with output:

Example 1: Python Program to Print Odd Numbers from 1 to N using For Loop

```# Python Program to Print Odd Numbers from 1 to N

num = int(input(" Please Enter any Maximum Number : "))

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

Output:

```Please Enter any Maximum Number :  15
1
3
5
7
9
11
13
15
```

Example 2: Python Program to Print Odd Numbers from 1 to N without If Statement

```# Python Program to Print Odd Numbers from 1 to N wihtout using if statement

num = int(input(" Please Enter any Maximum Number : "))

for number in range(1, num + 1, 2):
print("{0}".format(number))
```

Output:

```Please Enter any Maximum Number :  15
1
3
5
7
9
11
13
15
```

Example 3: Python Program to Print Odd Numbers using While Loop

```# Python Program to Print Odd Numbers from 1 to N using while loop

num = int(input(" Please Enter the Maximum Value : "))

number = 1

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

Output:

```Please Enter any Maximum Number :  15
1
3
5
7
9
11
13
15
```

Example 4: Python Program to Print Even Numbers from 1 to N using For Loop

```# Python Program to Print Even Numbers from 1 to N using for loop

num = int(input(" Please Enter the Maximum Number : "))

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

Output:

```Please Enter the Maximum Number :  15
2
4
6
8
10
12
14
```

Example 5: Python Program to Print Even Numbers from 1 to N without If Statement

```# Python Program to Print Even Numbers from 1 to N without using if statement

num = int(input(" Please Enter the Maximum Value : "))

for number in range(2, num+1, 2):
print("{0}".format(number))
```

Output:

```Please Enter the Maximum Number :  15
2
4
6
8
10
12
14
```

Example 6: Python Program to Print Even Numbers from 1 to N using While Loop

```# Python Program to Print Even Numbers from 1 to N  using while loop

num = int(input(" Please Enter the Maximum number : "))

number = 1

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

Output:

```Please Enter the Maximum Number :  15
2
4
6
8
10
12
14
```