Q:

Write a Python program to calculate the sum and average of n integer numbers. Input 0 to finish

0

Write a Python program to calculate the sum and average of n integer numbers. Input 0 to finish

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used python 3.7 compiler for debugging purpose.

print("Input some integers to calculate their sum and average. Input 0 to exit.")
 
count = 0
sum = 0.0
number = 1
 
while number != 0:
    number = int(input(""))
    sum = sum + number
    count += 1
 
if count == 0:
    print("Input some numbers")
else:
    print("Average and Sum of the above numbers are: ", sum / count)

Result:

Input some integers to calculate their sum and average. Input 0 to exit.

10

20

30

40

50

0

Average and Sum of the above numbers are:  25.0

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a Python program to find the median of three... >>
<< Write a Python program to create the multiplicatio...