# How To Find The Average Of 3 Numbers In Python

Last Updated : Jan 1, 2023 In this tutorial we will show you the solution of how to find the average of 3 numbers in python, the average or arithmetic mean of a collection of numbers is calculated by adding the numbers and then dividing them by the number of numbers in the collection.

The arithmetic mean is used in almost all scientific disciplines for analysis.

For example, consider the collection of numbers - 6, 6, 6. The arithmetic mean, or you can say that the average is (6+6+6)/3 = 6.

## Step By Step Guide On How To Find The Average Of 3 Numbers In Python :-

Python provides some methods that you can use in your program to find the average of any three numbers.

• Using calculations
• Using the for loop
• Using the built-in functions
```number1 = int(input("Please first number:"))
average = (number1 + number2 + number3) / 3
print("The average of three numbers: " , average)
numbers_str = input("Enter numbers separated by spaces: ")
numbers = [float(num) for num in numbers_str.split()]
total = 0;
for x in numbers:
total = total + x
print("Average of ", numbers, " is ", total / len(numbers))

# Using the built-in functions
print("Average of ", numbers, " is ", sum(numbers) / len(numbers))```
1. In the first approach, we will use basic mathematics to calculate the average of three numbers.
2. In the first three lines, there are three variables named number1, number2, and number3.
3. These variables will store the values that are given by the user in the input() function. The input() method will take input from the user. The input taken from the user will be of a string datatype.
4. We have to convert that string datatype into an integer datatype to perform this operation. The int() function will convert the input given by the user into an integer datatype.
5. In the next line, there is a variable named “average”, which will store the value of the expression. Python will first execute the addition operation of three numbers because the addition operation takes place within the brackets.
6. After that, it will divide the addition of those three numbers by 3 and store the result in the variable average.
7. In the next line there is a print statement which will print the value of the average variable.
8. In the next approach, you can use a for loop to calculate the addition of numbers and then divide them by the total number of number of elements.
9. In the next line, there is a variable named numbers_str, which will store the values inserted by the user. In the next line, there is a list variable named “numbers”, which will store the individual elements entered by the user.
10. In the next line, there is a variable named total which is initialized to the value of 0. In the next line, there is a for loop that will iterate through the list numbers and sum all elements into the total variable.
11. In the next line, the print statement will print the average of the numbers by dividing the total by the length of the numbers list.
12. In the next line, there is a comment saying that “Using the built-in functions” is the third method you can use.
13. In the next line there is just one print statement which will perform addition and division of the list numbers and print the average. The sum() function will add all the elements of the list numbers.

## Conclusion :-

So finally, in conclusion, we can say that with the help of this tutorial, you can now find the average of any three numbers in a Python program.

You can use any of the methods mentioned above that you find easy to understand. All the methods will work fine.

I hope this tutorial on how to find the average of 3 numbers in python helps you and the steps and method mentioned above are easy to follow and implement.