wap to print the sum of odd and even number from 1 to 100 in python
Answers
Answered by
4
Answer:
Hey! Here is your python code...
sum_odds = 0
sum_evens = 0
for i in range(101):
if i%2 == 1:
sum_odds+=i
else:
sum_evens+=i
print('Sum of all odd numbers from 1 to 100 = ', sum_odds)
print('Sum of all even numbers from 1 to 100 = ', sum_evens)
# HOPE THIS HELPS!!
Similar questions
Math,
5 months ago
Math,
11 months ago
English,
11 months ago
Computer Science,
1 year ago
Biology,
1 year ago