Answer to Question #118694 in Python for Nasir Khan

Question #118694
Write a program that reads in a series of numbers and adds them up until the user enters zero (this stopping value is often called a rogue value).
1
Expert's answer
2020-05-29T13:18:06-0400
ROGUE_VALUE = 0
sum = 0
while True:
    number = float(input("Enter number:"))
    if number == ROGUE_VALUE:
        break
    sum += number


print("sum is {}".format(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