擅长:python、mysql、java
<p>首先,你有压痕问题。第二,比较字符串和int。然后,比较。。。你知道吗</p>
<pre><code>>>> (350 - 300) / 100
0
>>> (350 - 300) / float(100)
0.5
</code></pre>
<p>你应该自己检查,但是<code>round(0) = 0</code>,和<code>round(0.5) = 1</code>。你知道吗</p>
<hr/>
<p>下面是解决问题的代码</p>
<pre><code>weight = int(raw_input("What are the weight of you parcel: "))
if weight <= 1000:
if weight <= 300:
cost = 5
else:
cost = 5 + 2 * round((weight - 300) / float(100))
print("Your parcel cost: {}".format(cost))
else:
print("Maximum weight for small parcel exceeded.")
print("Use large parcel service instead.")
</code></pre>