Learn about the Program to find Average of 10 Numbers in Python in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
Program to find Average of 10 Numbers in Python
# Python program to find the average of ten numbers
# stores sum of all numbers
total_sum = 0
for n in range (10):
num = float(input('Enter a number: '))
total_sum += num
# calculate average
avg = total_sum / 10
# print average
print('Average of numbers = %0.2f' %avg)
Output:
Enter a number: 1 Enter a number: 2 Enter a number: 3 Enter a number: 4 Enter a number: 5 Enter a number: 6 Enter a number: 7 Enter a number: 8 Enter a number: 9 Enter a number: 10 Average of numbers = 5.50
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Find the Average of 5 Numbers using Function in Python