商业网站成功的原因,在线营销推广,沈阳铁西做网站公司,wordpress做在线商城要求:某商店T恤的价格为35元/件#xff08;2件9折#xff0c;3件以上8折#xff09;,裤子的价格为120 元/条#xff08;2条以上9折#xff09;小明在该店买了3件T恤和2条裤子,请计算并显示小明应该付多少钱?
代码如下#xff1a;
tshirt_price 35 # T恤的单价
pan…要求:某商店T恤的价格为35元/件2件9折3件以上8折,裤子的价格为120 元/条2条以上9折小明在该店买了3件T恤和2条裤子,请计算并显示小明应该付多少钱?
代码如下
tshirt_price 35 # T恤的单价
pants_price 120 # 裤子的单价tshirt_quantity 3 # T恤的数量
pants_quantity 2 # 裤子的数量total_tshirt_price tshirt_price * tshirt_quantity # 计算T恤总价
total_pants_price pants_price * pants_quantity # 计算裤子总价if tshirt_quantity 3:total_tshirt_price * 0.8 # 若购买T恤数量大于等于3享受8折优惠
elif tshirt_quantity 2:total_tshirt_price * 0.9 # 若购买T恤数量大于等于2享受9折优惠if pants_quantity 2:total_pants_price * 0.9 # 若购买裤子数量大于等于2享受9折优惠total_price total_tshirt_price total_pants_price # 计算总价格print(f小明应该付款{total_price}元)