Python Practice › Loop Programs › Program 46

Count odd numbers 1 to 100

EasyLoop Programs · 46 of 90

Write a Python program to count the odd numbers from 1 to 100.

Advertisement
Output
50

Approach

  1. Increase a counter for each number with remainder 1.

Solution

Python
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.

More loop programs

← All 90 Loop Programs

Leave a Comment