Skip to content

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

  • by

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.