Write a program that allows a user to input 4 variables with decimal values only, checks for the largest amongst them, calculate their average and prints the output on screen
from decimal import Decimal
number_list = []
for i in range(4):
number_list.append(Decimal(input('Number ' + str(i + 1) + ': ')))
sum_numbers = Decimal(0)
max_number = number_list[0]
for n in number_list:
sum_numbers += n
if max_number < n:
max_number = n
average_numbers = sum_numbers / len(number_list)
print('average=', average_numbers)
print('maximum number=', max_number)
Comments
Leave a comment