好的,所以我对编程很陌生。我已经开始自学python-3.2,并尝试编写一个程序来显示任何餐厅账单的提示(小费分别为15%和20%)。
我不断得到:

Traceback (most recent call last):
  File "/home/marian/restaurantbilltotal.py", line 6, in <module>
    print(fifteen ("Plus a 15% tip: "))
TypeError: 'int' object is not callable tip


我写的代码是:

#Restaurant bill total

bill = int(input("Restaurant bill total: "))

fifteen = (bill // 100) * 15 + bill
print(fifteen ("Plus a 15% tip: "))

twenty = (bill // 100) * 20 + bill
print(twenty ("Plus a 20% tip: "))

input("\n\nPress the enter key to exit.")


请帮忙,但是请记住,我才刚刚开始学习如何编程:-)。谢谢。

最佳答案

bill = int(input("Restaurant bill total: "))

fifteen = (bill * 0.15)

twenty = (bill * 0.20)

print("Your Actual bill : ", bill)
print("Bill with 15% additional charge : ", bill+fifteen)
print("Bill with 20% additional charge : ", bill+twenty)

input("\n\nPress the enter key to exit.")

关于python - python 3.2无法调用'int'对象,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18297167/

10-11 18:56