快递计价,只能计算超重部分计价,会忽略首重计价金额。

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 :point_right:#这里的monye不会被计算。
print(“***
您当前快递地址是:”,name,”,重量:”,word,”公斤,金额:”,round(amount,2),”元!”)

money=float(input("请输入付款金额:"))
if money<amount:
    print("金额不足!")
else:
    print("****付款",money,"元!找零",round(money-amount,2),"元!")
讨论数量: 6
Jason990420
monye==monye1

The value of monye won’t be changed, and will be always kept as 0, so you got

amount=(word-3)price+0

Revise some statements, like

monye = monye1
2周前 评论
mingchengweitongguoshenhe (楼主) 1周前

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!

file

file

1周前 评论
Jason990420

你误解了我的回答

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),"元!")
输入地域编号:1
请输入重量:100
*** 您当前快递地址是:  东三省 / 宁夏 / 青海 / 海南 ,重量: 100  公斤,金额: 982  元!
请输入付款金额:1000.2
****付款 1000.2 元!找零 18.2 元!
1周前 评论
mingchengweitongguoshenhe (楼主) 1周前
mingchengweitongguoshenhe (楼主) 1周前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!