【发布时间】:2014-03-28 04:02:11
【问题描述】:
很抱歉用一个菜鸟问题打扰您,但我是 Python 新手。基本上这是一个家庭作业,我无法理解我做错了什么。我想我拥有我需要的一切,但我不断收到类型错误。任何帮助表示赞赏。谢谢!
def Main():
Weight = float(input ("How much does your package weigh? :"))
CalcShipping(Weight)
def CalcShipping(Weight):
if Weight>=2:
PricePerPound=1.10
elif Weight>=2 & Weight<6:
PricePerPound=2.20
elif Weight>=6 & Weight<10:
PricePerPound=float(3.70)
else:
PricePerPound=3.8
print ("The total shipping cost will be $%.2f") % (PricePerPound)
Main()
【问题讨论】:
-
@MartijnPieters 我认为你的意思是“按位”。
-
@SilasRay 你可能忽略了not。
-
我假设这是 Python 3 代码,对吧?
-
在我的一个关于布尔运算的问题上令人尴尬的误读,它会出现...... :)
-
它们都是布尔值,但一个是逻辑的,另一个是按位的。