找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 2322|回复: 3

[求助] 是of还是or

2

主题

6

帖子

6

积分

贫民

积分
6
追梦的少年 发表于 2018-8-10 23:07:42 | 显示全部楼层 |阅读模式
# 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岁
回复

使用道具 举报

47

主题

105

帖子

105

积分

侠客

积分
105
aggopie 发表于 2018-8-12 14:05:04 | 显示全部楼层
是or,估计是书上的错误
回复 支持 1 反对 0

使用道具 举报

47

主题

105

帖子

105

积分

侠客

积分
105
aggopie 发表于 2018-8-12 14:13:27 | 显示全部楼层
只要和上面的参数名称一样就可以了
回复 支持 1 反对 0

使用道具 举报

2

主题

6

帖子

6

积分

贫民

积分
6
追梦的少年  楼主| 发表于 2018-8-13 22:25:56 | 显示全部楼层
谢谢各位提出的意见,问题已经解决
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表