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

The value today of the following cash flows is $6,423.71 at an interest rate of 5.8 percent. What is the value of the Year 3 cash flow? Year Cash Flow 1 $1,665
Why is artwork that shows a historical event not a good source of factual details about the event? A.Most artists prefer to lie about events to make themselves
It is easier to lift the load as the load is pushed towards the wheel in a wheelbarrow​
The long-run aggregate supply curve shifts left if… Group of answer choices The capital stock decreases All of these answers are correct Immigration increase
A geometric sequence is shown on the graph below. What is the formula for the nth term of the sequence?
Newer aircraft jet catapult systems use magnets instead of steam. The launch still takes 1.19 seconds, but the acceleration is a about 47.41 m/s2. Determine th
what is described by the wavelength of a wave
Question 3 Find the domain and range of the function represented by the graph? A. Domain: -3 Range: -4<=y<=0 B. Domain: {-3, -2, -1, 0, 1} Range
If x is to 9 as 8 is to 12, then x is equal to _____
How much energy is transferred when 30.0 g of water is cooled from 25.0’C to 12.7’C