Answer to Question #282676 in Python for Fareeha

Question #282676

Maria has 4 bags while going to the airport she has been told that she take an average 50kg . Tell her to input the weight of each bag and calculate the mean weight

1
Expert's answer
2021-12-26T09:42:03-0500
total_weight= 0.0
n = 0
for i in range(4):
    weight = float(input(f'Input the weight of {i+1}-th bag: '))
    if weight <= 0:
        break
    total_weight += weight
    n += 1
avg_weight = total_weight / n
if total_weight > 50:
    print(f'The total weight of {n} bags is {total_weight} is overweighted')
else:
    print(f'The total weight of {n} bags is {total_weight}')
print(f'Average weight of bags is {avg_weight} kg')

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