Python Practice › Loop Programs › Program 51
Sum of odd numbers 1 to 100
Write a Python program to calculate the sum of all odd numbers from 1 to 100.
Output
2500
Approach
- Loop over odd numbers and add them.
Solution
total = 0for n in range(1, 101, 2): total += nprint(total)Output
2500
Learn the concept
New to this topic? Read the lesson, then come back.