第五题
戏唱故梦2025-04-10
代码
row = float(input("请输入消费金额:"))
x = row
y = 0
discounts = [1, 0.9, 0.8, 0.7]
for i in range(len(discounts)):
if x > 0:
if i == len(discounts):
amount = min(x, len(discounts) - 1)
y += x * discounts[i]
else:
y += min(x, 1000) * discounts[i]
x -= 1000
print(f"支付金额为:{y}")
运行结果
请输入消费金额: 1500
支付金额为:1350.0