2021年7月3日 星期六

[ Python ] 判斷 - if、elif、else

一、介紹

官網:https://docs.python.org/3.11/reference/compound_stmts.html#the-if-statement

二、if

score = int(input("請輸入成績"))

if score >= 60:

    print("成績及格!")


三、if...else

if score >= 60:

    print("大於60")

else:

    print("小於60")


四、if...elif...else

if score >= 60:

   print("大於60")

elif score == 100:

    print("等於100")

elif score == 0 :

    print("等於0")

else:

    print("其他") 

沒有留言:

張貼留言

影片的問題請留在影片的留言區裡。
部落格不會另外通知給我,所以很難發現你有留言。