How to find the sum of odd numbers from 1 to n using loops in python?

Jihan Binte Jashim
2 min readSep 14, 2022

--

So some days ago I had an exam named “Scripting with Python”. I was reviewing previous years' questions and saw a repeat question titled “How to find the sum of odd numbers from 1 to n using loops in python” or “Find the sum of 1+3+5+…..+99 in python” or similar types of questions. And all of these questions were answered were the only program we use for/while loops to bring results. Though it’s such a common program there are few places where I could find the proper program. Also, many people who know python programming for them it’s very easy but some students who quite don't understand programming for them I thought to write this up.

Sum of odd numbers from 1 to n using for loop

Sum of odd numbers from 1 to n using for loop

Sum of odd numbers from 1 to n using while loop

Sum of odd numbers from 1 to n using while loop

So, that was it! hope this will be helpful for some people. Thanks for checking out. See you later — ciao!

--

--

Jihan Binte Jashim
Jihan Binte Jashim

No responses yet