我正在编写一个简单的程序,它在条件为if-else时执行。我的程序接收用户输入的物体重量,单位为kg,浮点数,并打印出装运价格。通过使用while,我想将程序扩展到功能,并计算多个软件包的总价。程序应加载数据包重量,直到用户输入一个空行或一个小于等于0的数字。然后程序将打印所有包的总价
代码如下所示:
def packagePrice():
weightInKg = float(input(" Enter the value of weight:"))
totalPrise = 0
while weightInKg != "" or weight <= 0:
if weightInKg <= 10:
price = 149
elif 10 < weightInKg <= 100:
price = 500
elif weightInKg > 100:
print ("Not allowed")
totalPrise+= price
print(totalPrise)
weightInKg = float(input(" Enter the value of weight:"))
packagePrice()
但它不能正常运行 有人帮忙吗
这能回答问题吗
相关问题 更多 >
编程相关推荐