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

Solve the equation: 28 - 2x = 30
) Which expressions are equivalent? Choose ALL that apply. 94 36 9.9.9.9 D 4 to the ninth power 9 to the fourth power
TRUE OR FALSE: Abraham Lincoln wanted all Confederate generals prosecuted for treason.
◕‿↼ Please Help Asap, Tysm! → Match these items ← .send out .controls heredity .groups of tissues working together .take in _______________________________ .sub
The height of a tree is 4 m.Another tree is 30% shorter.Find the height of the shorter tree in metres and centimetres.​
Multiply 16,3,and 29, and then subtract 17
Please answer the science question FAST!
which english king established a new justice system that included courts and juries​
I peered up into the molten lava eyes of the Greek god singing on stage A. personification B. metaphor C. imagery D. allusion
Please help due tonight