exercise003_商品折扣

 
 
# coding=utf-8
# 3:一家商场在降价促销。如果购买金额50-100元(包含50元和100元)之间,会给10%的折扣,
# 如果购买金额大于100元会给20%折扣。
# 编写一程序,询问购买价格,再显示出折扣(%10或20%)和最终价格

for num in range(0,10):
    price = int(raw_input("请输入金额:"))
    if 50 <= price <= 100:
        print("给10%的折扣,还需支付{0}元".format(price*(1-0.1)))
    elif price > 100:
        print("给20%的折扣,还需支付{0}元".format(price*(1-0.2)))
    else:
        print("不满足折扣金额,需支付{0}元".format(price*(1-0.0)))
请输入金额:0
不满足折扣金额,需支付0.0元
请输入金额:22
不满足折扣金额,需支付22.0元
请输入金额:222
给20%的折扣,还需支付177.6元
请输入金额:50
给10%的折扣,还需支付45.0元
请输入金额:100
给10%的折扣,还需支付90.0元
请输入金额:

猜你喜欢

转载自blog.csdn.net/weixin_42652708/article/details/80985472
003