【发布时间】:2017-12-07 00:45:36
【问题描述】:
# Tipper Program
# User enters the bill total and the program computes two amounts,
# a 15 percent tip and a 20 percent tip
print("\t\t\t ** ** ** ** ** ** ** ** ** **")
print("\n\t\t\t\t Tip Calculator")
print("\n\t\t\t ** ** ** ** ** ** ** ** ** **")
bill = input("\nPlease enter your restaurant's bill total: ")
tip_15 = bill * 0.15
tip_20 = bill * 0.20
float(print("\n\nA 15% tip for this bill comes out to ", tip_15))
float(print("\nA 20% tip for this bill comes out to ", tip_20))
input("\n\nPress the enter key to exit.")
在我输入账单总额后,应用程序一直关闭。有解决此问题的建议吗?
【问题讨论】:
-
您将打印语句转换为浮点数?从倒数第二行和第三行删除
float() -
一般提示:从
cmd.exe运行程序(假设是Windows)。如果您只是双击它,它会在出现错误时立即退出,并且您将无法阅读有用的错误消息。 -
@Blorgbeard:你错过了最后的
input("\n\nPress the enter key to exit.")吗? -
@martineau 如果在该行之前发生错误则不会执行
标签: python python-3.x input casting user-input