我试图用Python编写一个简单的tip计算器,但我需要它始终输出两个小数位。对于一些整数,比如100,它只给出一个小数点,我该怎么办?在
这是我的代码:print("Only input numbers, do not input dollar signs or letters")
subtotalprice = eval(input("What is the bill total?: "))
percent10 = subtotalprice * 0.1
percent15 = subtotalprice * 0.15
percent20 = subtotalprice * 0.2
percent10_2 = str(round(percent10, 2))
percent15_2 = str(round(percent15, 2))
percent20_2 = str(round(percent20, 2))
percent10total = subtotalprice * 1.10
percent15total = subtotalprice * 1.15
percent20total = subtotalprice * 1.20
percent10total_2 = str(round(percent10total, 2))
percent15total_2 = str(round(percent15total, 2))
percent20total_2 = str(round(percent20total, 2))
print("If you want to leave a 10% tip, th