wapp to print sum of odd no.(s) and even no.(s) using for() loop(python)
Answers
Answered by
0
Answer:
maximum = int(input(" Please Enter the Maximum Value : "))
Oddtotal = 0
Eventotal = 0
for number in range(1, maximum+1):
if(number % 2 != 0):
Oddtotal = Oddtotal + number
else:
Eventotal = Eventotal + number
print("The Sum of Odd Numbers from 1 to {0} = {1}".format(number, Oddtotal))
print("The Sum of Odd Numbers from 1 to {0} = {1}".format(number, Eventotal))
Similar questions