快递计价,只能计算超重部分计价,会忽略首重计价金额。
name1=”东三省/宁夏/青海/海南”
num1=”1”
monye1=12
price1=10 #超过3公斤部分的价格
name2=”新疆/西藏”
num2=”2”
monye2=20
price2=20#超过3公斤部分的价格
name3=”港澳台/国外”
num3=”3”
monye3=”暂不接收!”
price3=”请联系总公司!”
name4=”其他”
num4=”4”
monye4=10
price4=5#超过3公斤部分的价格
monye=0
price=0
name=””
num=input(“输入地域编号:”)
word=int(input(“请输入重量:”))
if num==num1:
name=name1
monye==monye1
price=price1
elif num==num2:
name=name2
monye==monye2
price=price2
elif num==num4:
name=name4
monye==monye4
price=price4
else:
print(“暂不接收,请联系总公司!”)
if price!=0:
amount=(word-3)price+monye
#这里的monye不会被计算。
print(“***您当前快递地址是:”,name,”,重量:”,word,”公斤,金额:”,round(amount,2),”元!”)
money=float(input("请输入付款金额:"))
if money<amount:
print("金额不足!")
else:
print("****付款",money,"元!找零",round(money-amount,2),"元!")
关于 LearnKu
The value of
monyewon’t be changed, and will be always kept as 0, so you gotRevise some statements, like
Sorry, I forgot to mention the program used, it is Python.
Moni==Moni 1
It has already been declared in ‘if’.
The problem encountered in practical use is that only the price of parts weighing over 3 kilograms was calculated during the calculation process, without including the starting unit price, which is very painful for me!
Based on my understanding, I have tried what you said and the calculation result is still the same, without adding the initial 3kg pricing!
The screenshot of the subsequent calculation shows the formula with the “*” restored
The above content is translated by Baidu. My English is not very good. If there is anything wrong, please understand!
你误解了我的回答