To calculate average ir arithmetic mean of numbers in python, you have to ask from user to enter some set of numbers say 5 numbers to find the average of those numbers as shown in the program given here.
Following python program ask from user to enter 5 numbers to find the average of all numbers:
# Python Program - Calculate Average of Numbers print("Enter 'x' for exit."); print("Enter any 5 numbers to find average: "); n1 = input(); if n1 == 'x': exit(); else: n2 = input(); n3 = input(); n4 = input(); n5 = input(); number1 = int(n1); number2 = int(n2); number3 = int(n3); number4 = int(n4); number5 = int(n5); sum = number1 + number2 + number3 + number4 + number5; average = sum/5; print("Average of entered 5 numbers is",average);
Here is the sample run of the above Python program shows how to calculate and print average of numbers:
Above is the initial output asking from the user to enter any five numbers to find average of all the given 5 numbers by users as shown in the below sample output:
Here is the same program directly written and run on python shell:
You may also like to learn or practice the same program in other popular programming languages: