Question: Write a program that receives a list of numbers from the user ( keyboard ) and print the sum of odd numbers. For example, if

Write a program that receives a list of numbers
from the user (keyboard) and print the sum of
odd numbers. For example, if the user enters
11,5,2,6,9, the program should print the sum of
11,5, and 9, which is 25(=11+5+9).
If the user enters x, the loop will exit.
As long as the user does not enter x, your program
Ans: while True:
User=input("Enter a number or enter 'x' to quit:")
if User=='x':
break
print("Quit Program")
elif oddSum=0
for i in range(1,endPoint+1,2):
oddSum += i
print("sum of odd numbers from 1 to "+str(endPoint)+" is "+str(oddSum)+".")
should keep receiving numbers.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!