Python Practice › Loop Programs › Program 45
Count even numbers 1 to 100
Write a Python program to count the even numbers from 1 to 100.
Output
50
Approach
- Increase a counter for each number with remainder 0.
Solution
count = 0for n in range(1, 101): if n % 2 == 0: count += 1print(count)Output
50
Learn the concept
New to this topic? Read the lesson, then come back.