Back to: Python Basics
0
Aim :- Python Program To Find Average of Five Numbers
def Average():
no1 = int(input("Enter the first number : "))
no2 = int(input("Enter the second number : "))
no3 = int(input("Enter the third number : "))
no4 = int(input("Enter the fourth number : "))
no5 = int(input("Enter the fifth number : "))
ans = (no1 + no2 + no3 + no4 + no5)/5
print("The first number is",no1)
print("The second number is",no2)
print("The third number is",no3)
print("The fourth number is",no4)
print("The fifth number is",no5)
print("Average =",ans)
Average()
Algorithm :-
Step 1 :- Read The Numbers.
Step 2 :- Calculate the average by adding all the numbers and dividing by five.
Step 3 :- Along with the numbers display the average.
P.N. : All the post on this website are for demonstration and education purpose only.
Student should perform all the practicals for there personal copies.
Prashant yadav
#average using list
#taking the input from user
arr=list(map(int,input(“Enter the numbers : “).split()))
#map() is an iterator and split() is used to split every element in the list
print(arr) #display the value entered in list
avg=sum(arr)/len(arr) #formula
print(‘Average : ‘,avg)
Thank You Prashant !