|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
可以运行的
# AtlantaPizza.py – a simple pizza cost calculator
# Ask the person how many pizzas they want, get the # with eval()
number_of_pizzas = eval( input("How many pizzas do you want: ") )
# Ask for the menu cost of each pizza
cost_per_pizza = eval( input("How much does each pizza cost: ") )
# Calculate the total cost of the pizzas as our subtotal
subtotal = number_of_pizzas * cost_per_pizza
# Calculate the sales tax owed, at 8% of the subtotal
tax_rate = 0.08 # we store 8% as the decimal value 0.08
sales_tax = subtotal * tax_rate
# Add the sales tax to the subtotal for the final total
total = subtotal + sales_tax
# Show the user the total amount due, including tax
print("The total cost is $", total)
print("This includes $", subtotal, "for the pizza and")
print("$", sales_tax, "in sales tax.")
# AtlantaPizza.py - a simple pizza cost calculator
# Ask the person how many pizzas they want, get the # with eval()
number_of_pizzas = eval( input("How many pizzas do you want: ") )
# Ask for the menu cost of each pizza
cost_per_pizza = eval( input("How much does each pizza cost: ") )
# Calculate the total cost of the pizzas as our subtotal
subtotal = number_of_pizzas * cost_per_pizza
# Calculate the sales tax owed, at 8% of the subtotal
tax_rate = 0.08 # we store 8% as the decimal value 0.08
sales_tax = subtoal * tax_rate
# Add the sales tax to the subtotal for the final total
total = subtotal + sales_tax
# Show the user the total amout due, including tax
print("The total cost is $",total)
print("This includes $", subtotal, "for the pizza and")
print("$",sales_tax, "in sales tax.")
大神们,帮我看看,错误出在哪里了,我不懂
错误提示:
How many pizzas do you want: 1
How much does each pizza cost: 1
Traceback (most recent call last):
File "D:\Program Files (x86)\python\lianxiti\chepter3\atlantapizza.py", line 14, in <module>
sales_tax = subtoal * tax_rate
NameError: name 'subtoal' is not defined
|
|