---
# System prepended metadata

title: Python教學 L5小作業用

---

# Python教學 L5小作業用

```python=
print("輸入總金額，將會依據金額打折，並輸出打折後的金額")
money = int(input("請輸入購買總金額："))
if money < 1000:
    print("抱歉，沒有折扣唷！")
    discount = 1.0
elif money <= 4999:
    print("享有9折優惠唷！")
    discount = 0.9
elif money <= 9999:
    print("享有8折優惠唷！")
    discount = 0.8
else:
    print("享有7折優惠唷！")
    discount = 0.7
#round(a,b)表示將a值在小數點第b位四捨五入
money = int(round(money*discount,0))
print("打折後總金額為：",money)

```
