Answer to Question #287091 in Python for Micky

Question #287091

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

1
Expert's answer
2022-01-12T18:10:43-0500
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS