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’s two regions imported the most Africans during the height of the slave trade
Which of the foods below would be considered the least nutrient-dense? a. oatmeal b. eggs c. whole milk d. margarine e. orange juice
i need a short paragraph summary for act 5 for macbeth for all scenes
Somebody helppppp pleassse
PLS PLS PLS HELP! TIMED! Consider the diagram below. Which statement accurately describes the diagram? A) The temperature increases after dissolution, and the p
Jamie has been working hard at soccer practice and doesn't feel well she has cramps in her legs pale moist skin a fever of 101 degrees Fahrenheit and feels weak
Tyree is determining the distance of a segment whose endpoints are A(–4, –2) and B(–7, –7). See image at the top^ Which best describes the accuracy of Tyree’s s
Which three religions developed in East Asia?
Rome's twelve tables and Justinian's code contributed to which type of government system?
A process by which the human brain retains an image for a fraction of a second longer than the eye records it is called the