Contents
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
sum = x + y
average = sum / 2
print(f'Average = {average}')
Run Output
Average = 3.5
Summary
In this tutorial of Python Examples, we learned how to find the average of given two numbers.
Related Tutorials
- Python – Sum of Two Numbers
- Python Complex Number – Initialize, Access
- How to Get Number of Axes in Pandas DataFrame?
- Python Program to Add Two Numbers
- How to Get Number of Elements in Pandas DataFrame?
- Python String – Find the number of overlapping occurrences of a substring
- Reverse a Number in Python
- Python – Sum of First N Natural Numbers
- How to Swap Two Numbers in Python?
- Python – Factorial of a Number