We will develop a program on how to find the average of 10 numbers in Python. The average is defined as the mean value which is equal to the ratio of the sum of the number of a given set of values to the total number of values present in the set. Here, we will calculate the average of four numbers using various methods.

**How to find the average of numbers:**

**Average Formula** = Total sum of all numbers / Number of items in the set

Average = (x1+x2+x3+…+xn)/n

**Mathematically,**

Inputs: a=4, b=2, c=8, d=6, e=5, f=5, g=6, h=8, i=2, j=4

Average = (a+b+c+d+e+f+g+h+i+j)/10 = (4+2+8+6+5+5+6+8+2+4)/10 = 50/10 = 5

## Take 10 integers from Keyboard using a Loop and Print their Average value on the Screen in Python

This python program also performs the same task but with different methods. In this program, we are using For Loop to take inputs and calculate the sum of those numbers. Then, calculate the average of those numbers and finally, print the average value.

```
# Python program to find the average of ten numbers
# denotes total sum of ten numbers
total_sum = 0
for n in range (10):
# take inputs
num = float(input('Enter number: '))
# calculate total sum of numbers
total_sum += num
# calculate average of numbers
avg = total_sum / 10
# print average value
print('Average of numbers = %0.2f' %avg)
```

Output:-

Enter number: 5

Enter number: 3.4

Enter number: 15

Enter number: 3.6

Enter number: 4.5

Enter number: 25

Enter number: 3.82

Enter number: 0.45

Enter number: 23

Enter number: 7

Average of numbers = 9.08

## Python Program to Calculate the Average of 10 Number

This Python program is the simplest and easiest way to calculate the average of 10 numbers. We will take ten numbers while declaring the variables and calculate the average value of those numbers using the average formula. Then, the average value will be displayed on the screen.

```
# Python program to find average of ten numbers
# take inputs
num1 = 1
num2 = 2
num3 = 3
num4 = 4
num5 = 5
num6 = 6
num7 = 7
num8 = 8
num9 = 9
num10 = 10
# calculate average
avg = (num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8 + num9 + num10) / 10
# print average value
print('The average of numbers = %0.2f' %avg)
```

Output:-

The average of numbers = 5.50

## Average of 10 Numbers in Python

In the previous program, inputs are hardcoded in the program but in this program, inputs will be provided by the user. Inputs are scanned using the input() function and stored in the variable num1, num2, num3, num4, num5, num6, num7, num8, num9, and num10.

Program description:- **Write a python program which input ten numbers and display their average.**

```
# Python program to find average of ten numbers
# take inputs
num1 = float(input('Enter first number: '))
num2 = float(input('Enter second number: '))
num3 = float(input('Enter third number: '))
num4 = float(input('Enter four number: '))
num5 = float(input('Enter fifth number: '))
num6 = float(input('Enter six number: '))
num7 = float(input('Enter seven number: '))
num8 = float(input('Enter eight number: '))
num9 = float(input('Enter nine number: '))
num10 = float(input('Enter ten number: '))
# calculate average
avg = (num1 + num2 + num3 + num4 + num5
+ num6 + num7 + num8 + num9 + num10) / 10
# print average value
print('The average of numbers = %0.2f' %avg)
```

Output:-

Enter first number: 4

Enter second number: 8

Enter third number: 2.6

Enter four number: 85

Enter fifth number: 5.7

Enter six number: 9

Enter seven number: 0.4

Enter eight number: 15

Enter nine number: 30

Enter ten number: 3.5

The average of numbers = 16.32

## Find the Average of 10 Numbers using Functions

We can also take the help of a function to find the average of 10 numbers in python. A function is a block of code that performs a specific task.

```
# Python program to find average of ten numbers using function
def avg_num(num1, num2, num3, num4, num5, num6,
num7, num8, num9, num10): #user-defined function
avg = (num1 + num2 + num3 + num4 + num5 + num6
+ num7 + num8 + num9 + num10) / 10 #calculate average
return avg #return value
# take inputs
num1 = float(input('Enter first number: '))
num2 = float(input('Enter second number: '))
num3 = float(input('Enter third number: '))
num4 = float(input('Enter four number: '))
num5 = float(input('Enter fifth number: '))
num6 = float(input('Enter six number: '))
num7 = float(input('Enter seven number: '))
num8 = float(input('Enter eight number: '))
num9 = float(input('Enter nine number: '))
num10 = float(input('Enter ten number: '))
# function call
average = avg_num(num1, num2, num3, num4, num5,
num6, num7, num8, num9, num10)
# display result
print('The average of numbers = ',average)
```

Output:-

Enter first number: 5

Enter second number: 2

Enter third number: 65

Enter four number: 56

Enter fifth number: 5.54

Enter six number: 56

Enter seven number: 2.6

Enter eight number: 3.9

Enter nine number: 15

Enter ten number: 0.8

The average of numbers = 21.184