用于计算膳食成本的Python脚本(输入您自己的成本)

时间:2018-03-07 15:40:54

标签: python python-3.x math calculator

我想要一个可以告诉我在吃东西时花多少钱的脚本,但我希望能够在运行脚本时输入值(不需要在配置中手动更改)

mealcost = input("How much does the meal cost? ")
taxamount = int(input("What's the tax (%)? "))
tipamount = int(input("What's the tip (%)? "))

print ("meal price: " + "£" + str(mealcost))
print('\n' * 2)


tax = (taxamount / 100)
print ("tax: " + str(taxamount) + "%")
print('\n' * 2)


tip = (tipamount / 100)
print ("tip: " + str(tipamount) + "%")
print('\n' * 3)
#=================================breaks here========================
mealcost = mealcost + mealcost * tax
total = mealcost + mealcost * tip

print ("total")

print("%.2f" % total)
wait = input ()

我不知道该怎么做才能修复它,并且非常感谢有人重新编写它以便它不会破坏。

1 个答案:

答案 0 :(得分:1)

git checkout b -b

不会起作用,因为

之后
mealcost = mealcost + mealcost * tax

mealcost是mealcost = input("How much does the meal cost? ") ,而不是int / float