某运输队为超市运送暖瓶500箱每箱装有6个暖瓶。已知每10个暖瓶的运费为5元损坏一个不但不给运费还要赔10元运后结算时运输队共得1332元的运费。编程输出损坏暖瓶的个数。用python的for编写
damage = 0 total_bottles = 500 * 6 for i in range(1, total_bottles+1): if i % 10 == 0: damage += 1 else: continue total_cost = total_bottles // 10 * 5 if damage > 0: total_cost -= damage * 10 net_profit = 1332 - total_cost print("损坏暖瓶的个数为:", damage) print("净利润为:", net_profit)
原文地址: https://www.cveoy.top/t/topic/efx1 著作权归作者所有。请勿转载和采集!