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

Could someone please help me with this answer thank you!
A Sound of Thunder By: Ray Bradburyidentify the step in the chain of causes and effects that travis says would occur if a time traveler accidentally killed eve
An inclined plane is 30 meters long and 2 meters high what is the mechanical advantage of the inclined plane
How are primary and secondary succession different from one another?
​LaTanya has refused to eat more than a few hundred calories a day for the past several months in an attempt to become more slender. As a result, she has lost a
13. Simplify this expression: 19-(-8) - (-14) = ?
Building blocks of protiens are
Esta película ___ de un crimen muy violento y no me gustó. A. Estaba escrita B. Estaba basada C. capturó d. Se trató
How did imperialism contribute to the start of world war I? A) Germany was the first to attempt to expand their empire. B) Germany's attempts to defend newly i
Samantha sends her son, Barry, to a preschool center on certain days. The cost of preschool is $45 per day along with a fixed monthly charge of $70. Last month,