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

what number has the same value as 50 tens??
I need help Writing an essay about Washington Irving and his stories "The Legend of Sleepy Hollow" and "Rip Van Winkle." I really need a thesis statement and ju
Write 1.2% in a fraction or mixed number in simplest form
How are oceanic ridges identified?
why is it incorrect to say the insulation 'keeps out the cold'
HELP ME PLS!put the verb in brackets in the correct tense.in some cases there is more than one possible answer.1.many people from the former communist bloc ____
What 1/11 as a decimal
Rewrte each sum as a product of the GCF of the addends and another number. 2. 15+45 3. 9+27
How do you estimate 403,446 396,755
The deck in Hopes backyard is round.It has 5 post evenly spaced around the edge to support a trellis. For her birthday party , she wants to connect each post to