dillonseanbarr dillonseanbarr
  • 23-10-2020
  • Computers and Technology
contestada

Does anyone know how to use a while loop and ask a user to input positive integers until the user enters 0 and print the sum so far after each input, then print final sum at the end in edhesive?

Respuesta :

Cytokine
Cytokine Cytokine
  • 23-10-2020

In python:

total = 0

while True:

   num = int(input("Enter a number: "))

   if num == 0:

       break

   total += num

print(f"The final sum is {total}")

Answer Link

Otras preguntas

According to the graph, what is the solution (ordered pair) of this system of equations?
The recurring cyclical experience of Israel from Joshua to Samuel was:.? 1.apostasy, servitude, repentance, deliverance 2.blessing, prosperity, apostasy, serv
Can I get the correct answer for this please.
2560 divided by 50 Thank you I gotta be an extra for me to get this stuff out to the shop I have so little money was my first place I gotta I love I'm glad I ha
The line passing through (11,y) and (2,0) is parallel to the line joining (7,5) and (-2,2). Find y.
60 minutes is 20% of x minutes
Please Help!!!!!!First you top off your gas tank in Olympia. You then drive your Hummer to Spokane, traveling 319.4 miles. You fill up your gas tank with 28.68
A drawer contains five pairs of socks that are brown, black, white, red, and blue. Claude takes the red socks out of the drawer. He doesn't want red socks so h
How many unique 13C NMR signals exist in the spectrum for the following compound? 4-methylpent-1-ene
Aniridia is a type of blindness due to a single dominant gene. Migraine headache is the result of a different dominant gene. A man with aniridia, but normal hea