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

Which of the following statements about biodiversity is not true?
Doing a cartwheel is an example of what type of transformation? Is it just rotation?
Why might the Romans have sought to create believable images in their sculptural works?
Plate tectonic theory states that the continents move around on the earth's crust, drifting in response to forces within the earth's mantle. What generalization
Which ruler became emperor after pushing back the Magyars who attacked from the east?
integrate (1/(x^2*sqrt(x^2-9))dx
What is the slope of the line graphed on the coordinate plane? A graph with a line running through coordinates (-2, 3) and coordinates (2, 6) PLS HELP MEH TAKIN
I have so much anxiety in life, what are ways that can help me control my anxiety?
Differentiate Between Mendelian and Chromosomal Disorder. Give two examples of each.
Please help me it's confusing