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
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')
Comments
Leave a comment