Python – Average of Two Numbers

Python Program to Find Average of Two Numbers

To find the average of two numbers in Python, first find the sum, and then divide the sum by 2.

We can use Addition Operator to find the sum, and Division Operator to divide the sum by 2. Since, we are finding the average of only two numbers, we divide the sum by 2.

Program

In this program, we shall take two numbers in x, y; and find their average.

Python Program

x = 5
y = 2

# Find sum of two numbers
sum = x + y

# Find the average
average = sum / 2
print(f'Average = {average}')
Run Code Copy

Output

Average = 3.5

Summary

In this tutorial of Python Examples, we learned how to find the average of given two numbers.

Related Tutorials

Code copied to clipboard successfully 👍