Learn about Python Program to Find Average of Two Numbers in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.
Python Program to Find Average of Two Numbers
The numbers are taken from the user input and the average of both numbers is calculated using a simple formula. The final result is displayed.
# Program to find average of two numbers #inputs num1 = float(input('Enter first number: ')) num2 = float(input('Enter second number: ')) # calculate average avg = (num1 + num2) / 2 # print value print('The average of numbers = %0.2f' %avg)
Enter first number: 5 Enter second number: 8 The average of numbers = 6.50
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Divide Two Integers Without using Division Operator in Python