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 will be the effect on the loudness of sound if the amptitude is doubled and halved?
How much pure alcohol must be added to 400 ml of a 15% solution to make its strength 32%
5p-14=8p+4 step by step
The sum of two numbers is 8, and the sum of their squares is 34. What is the smaller number?
A pot is heated on a stove . Which process causes the metal handle of them pot to also become hot?
Exercises1. The sum of both numbers of a number is 14. On having exchanged the numbers of the tens with that of the units, the number increases in 18. It finds
What value of c makes x^2 +5x+c a perfect square.
Why was the French alarmed after the Belgium government seized the Congo from King Leopold?
Paul's average for 3 tests was 85. The average of his scores for the first 2 tests was also 85. What was his score for the third test?
how could the western democracies prevented World War ll