Respuesta :
Answer:
theSum = 0.0#defined in the question.
count=0 #modified code and it is used to intialize the value to count.
data = input("Enter a number: ") #defined in the question.
while data != "": #defined in the question.
number = float(data) #defined in the question.
theSum += number #defined in the question.
data = input("Enter the next number or press enter to quit ") #defined in the question "only some part is modified"
count=count+1#modified code and it is used to count the input to print the average.
print("The sum is", theSum)#defined in the question.
print("The average is", theSum/count) #modified code and it is used to print the average value.
output:
- If the user inputs as 1,4 then the sum is 5 and the average is 2.5.
Explanation:
- The above code is written in the python language, in which some part of the code is taken from the question and some are added.
- The question has a code that tells the sum, but that code is not print the average value of the user input value.
- To find the average, some codes are added, in which one count variable which is initialized at the starting of the program and gets increased by 1, when the user gives the value.
- Then that count divides the sum to print the average.