我需要根据包裹类型,重量以及交付的区域计算运费。我没有得到他的所有硬数据,所以我使用了一些展示位置,但这并不重要。问题是即使没有列出错误,运行程序只会返回一个空白页面,没有提示输入数字或类似的东西。
这是代码。
def main():
packageType = input('Please enter the package type: ')
rate = 0
zoneRate = 0
if packageType == 1:
rate += 1.25
elif packageType == 2:
rate += 1.5
elif packageType == 3:
rate += 1.75
elif packageType == 4:
rate += 2
weight = input('Please enter the weight: ')
if weight <= 2:
rate += 3.10
elif weight > 2 and weight <= 6:
rate += 4.20
elif weight > 6 and weight <= 10:
rate += 5.30
elif weight > 10:
rate += 6.40
zones = input('Please enter how many zones are crossed: ')
if zones == 1:
zoneRate += 5
if zones == 2:
zoneRate += 10
if zones == 3:
zoneRate += 15
cost = rate * zoneRate
print(('The shipping cost is: '), cost)
答案 0 :(得分:3)
你需要
def main():
# all of your code
# goes here
main()