我有问题,需要您的帮助!
这是代码:
kg_lemons = float(input())
kg_sugar = float(input())
water = float(input())
total_lemon_juice = kg_lemons * 980 #in mililiters need to multiply by 1000
total_lemonade = total_lemon_juice + 5 * 1000 + (0.3 * kg_sugar)
cups_made = total_lemonade / 150
money_made = cups_made * 1.20
print(f'All cups sold: {cups_made:.2f}')
print(f'Money earned: {money_made:.2f}')
最后,在我打印完之后,它必须显示数字:
All cups sold: 66
Money earned: 79.20
但是我得到了
All cups sold: 66.01
Money earned: 79.21
因此,我需要将其四舍五入到第二个小数(最小的数字)。我应该使用math.floor
吗?如果使用,怎么使用?