|
# Atlantapizza.py - a simple pizza cost calculator
# Ask for the how many pizzas they what, get the number with ever()
number_or_pizzas = eval(input("How many pizzas do you went?"))
# Ask for the menu cost of menu cost of each pizza
cost_per_pizza = eval(input("How much does each pizza cost?"))
# Calculate the sales tax cost of the pizzas as our subtotal
subtotal = number_or_pizzas * cost_per_pizza
# Calculate the sales tax owed, at 8% of the subtotal
tax_rate = 0.08 # 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.")
在第7行“number_or_pizzas”那里,是“or”还是"of"?(在书中是“of”但运行不起来)
我12岁
|
|