Dremendo Tag Line

Input decimal numbers and find their sum and average in Python

input() - Question 2

In this question, we will see how to input 5 decimal numbers in Python programming using the input() function and find their sum and average. To know more about input() function click on the input() function lesson.

Q2) Write a program in Python to input 5 decimal numbers and find their sum and average.

Program

print('Enter 5 decimal numbers')
a=float(input())
b=float(input())
c=float(input())
d=float(input())
e=float(input())
sum=a+b+c+d+e
avg=sum/5
print('Sum={:.2f}'.format(sum))
print('Average={:.2f}'.format(avg))

Output

Enter 5 decimal numbers
12.36
15.1
3.24
18.9
21.17
Sum=70.77
Average=14.15
video-poster