(1) not, and, or
優先權
動作
指令
#設定年份
year = 2000
#判斷閏年或平年
if year%400==0 or year%4==0 and year%100!=0:
print('閏年')
else:
print('平年')閏年
2. 使用小括號

自主練習
Last updated
#設定年份
year = 2000
#判斷閏年或平年
if year%400==0 or year%4==0 and year%100!=0:
print('閏年')
else:
print('平年')閏年

Last updated
#單價、數量、折價卷
price=120
amount=10
coupon=True
#計算總金額
total = price * amount
#(總金額大於2000元)而且(數量至少10個或是有折價卷), 可以打9折
if total > 2000 and (coupon or amount >=10):
total = int(total*0.9) #打9折
#顯示應付金額
print(f'{total:,}元')1,200元