Answer to Question #3241 in Python for Goh

Question #3241
Write a program that repeatedly asks a user to enter a number. The program will sum up all the number that the user keyed in. Terminate the program when the user enters -9, and display the sum of all the numbers entered by the user (exclude -9).
1
Expert's answer
2011-06-29T11:10:51-0400
sum = 0

while True:

number = float(input ("Enter a number: "))

if number == -9: break

sum += number

print ("The sum is", sum)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS