Dremendo Tag Line

Calculate average and check good or bad in Python

if else - Question 6

In this question, we will see how to input 5 decimal numbers and print good if their average is greater than 50, otherwise print bad in Python programming using the if else statement. To know more about if else statement click on the if else statement lesson.

Q6) Write a program in Python to input 5 decimal numbers and find their average. If the average is greater than 50 then print Good, otherwise print Bad.

Program

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

if avg>50:
    print('Good')
else:
    print('Bad')

Output

Enter 5 decimal numbers
86.23
75.18
92.10
69.35
78.14
Average=80.20
Good
video-poster