# -*- coding: utf-8 -*- """ Created on Fri Sep 9 11:08:48 2022 @author: cpresser """ # Sentinel loop # Allow user to enter numbers until they enter 0 # output sum and average #1. Initialization: # get a number from the user. Use input() # set sum to 0 value = input("Enter a number (0 to quit): ") sum = 0 n = 0 #start counting the number of numbers #2. Condition (for the while) # keep going as long as the number is not 0 # not equal: != (bang equal) while int(value) != 0: #while value != "0": #compare to string 0 #4. Repetition # add the number to sum sum = sum + int(value) n = n + 1 #added one more number #3. Step # ask for the next number. Use input() value = input("Enter a number (0 to quit): ") #AFTER THE LOOP # print sum and average print(f"The sum is {sum}.") print(f"The average is {sum/n}.")