我是新手(比如 2 周),正在尝试学习 Python 2.7x。我正在尝试做一个基本程序,让用户输入一顿饭的费用,并输出 0.15 小费的费用。我希望输出看起来像 23.44(显示 2 位小数)
我的代码:
MealPrice = float(raw_input("Please type in your bill amount: "))
tip = float(MealPrice * 0.15,)
totalPrice = MealPrice+tip
int(totalPrice)
print "Your tip would be: ",tip
print "Yout total bill would be: ",totalPrice
我的输出:请输入您的账单金额:22.22 您的小费将是:3.333 您的总账单将是:25.553