Python Program to Find the Average Of Two Numbers

Write a Python program to find the average of two numbers. This example accepts two integer numbers and calculates the sum and average.

x = int(input("Please Enter the First Number  = "))
y = int(input("Please Enter the Second number = "))


sumOfTwo = x + y

avgOfTwo = sumOfTwo / 2

flooravgofTwo = sumOfTwo // 2

print('The sum of {0} and {1}       = {2}'.format(x, y, sumOfTwo))
print('The Average of {0} and {1}   = {2}'.format(x, y, avgOfTwo))
print('Floor Average of {0} and {1} = {2}'.format(x, y, flooravgofTwo))
Python Program to Find the Average Of Two Numbers

This program allows users to enter two floating point numbers and finds the average of those values.

x = float(input("Please Enter the First  = "))
y = float(input("Please Enter the Second = "))


sumOfTwo = x + y

avgOfTwo = sumOfTwo / 2

flooravgofTwo = sumOfTwo // 2

print('The sum of {0} and {1}       = {2}'.format(x, y, sumOfTwo))
print('The Average of {0} and {1}   = {2}'.format(x, y, avgOfTwo))
print('Floor Avg of {0} and {1} = {2}'.format(x, y, flooravgofTwo))
Please Enter the First  = 22.9
Please Enter the Second = 14.7
The sum of 22.9 and 14.7       = 37.599999999999994
The Average of 22.9 and 14.7   = 18.799999999999997
Floor Avg of 22.9 and 14.7 = 18.0