Skip to content

Write a program to print the first 10 even numbers in Python | code

To write a program to print the first 10 even numbers in Python, you have a set range of for loop. In this example, you have to use max loop 10. Then if the current number % 2 == 0 matches the condition in the if statement then prints it.

Python program to print the first 10 even numbers

Simple example code.

maximum = 10

for number in range(1, maximum + 1):
    
    if number % 2 == 0:
        print(number)

Output:

Write a program to print the first 10 even numbers in Python

Python Program to Print Even Numbers from 1 to N

Print the even number from 1 to the user’s given number.

maximum = int(input("Enter the Maximum Value : "))

for number in range(1, maximum + 1):

    if number % 2 == 0:
        print("{0}".format(number))

Output:

Enter the Maximum Value: 5
2
4

Do comment if you have any doubts or suggestions on this Python print number code.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

1 thought on “Write a program to print the first 10 even numbers in Python | code”

  1. this example above give even numbers in first 10 number – so it basically does not answer the question – Write a program to print the first 10 even numbers in Python.
    I feel output to this question should be :
    0
    2
    4
    6
    8
    10
    12
    14
    16
    18
    20

    Correct me if I’m wrong, not offensive intention.

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading