Pythondex

Exercise

Loops Exercise: Print Even Numbers

In this exercise, you’ll practice using loops to print numbers and apply a condition to select only even numbers.

Task

Write a Python program that:

  • Prints all even numbers from 1 to 50
  • Uses a for loop and an if statement
  • Prints each number on a new line
  • Use % (modulus) operator to check if a number is even

Example Output

Solve