A_quantity = 10
B_quantity = 20
数量 数量
N = float (input('please enter the quantity of package: '))
X_total = float (N*99.00)
输入费
Q_discount = (0.2*X_total)
W_discount = (X_total*0.3)
输入总额的折扣
Y_total = (X_total-Q_discount)
M_total = (X_total-W_discount)
折扣的费用
def main ():
if N >= A_quantity:
print ('the total cost is $', \
format (Y_total, ',.2f'))
else:
if N >= B_ quantity:
print ('the total cost is $', \
format (M_total, ',.2f'))
main ()
结果应该是 792.00 美元的 10 个包
和 20 个套餐,售价 1,380.00 美元
然而第二条语句获得了 20% 的折扣,总计 1549.00 美元,而它应该只获得 30% 的折扣