P4B Quiz (13):條件判斷式 – if 相關敘述及使用 by KC 2023-03-23 written by KC 2023-03-23 0 comment Welcome to your quiz -「 P4B Quiz (13):條件判斷式 - if 相關敘述及使用」 Name Email 1. 以下執行結果是什麼? number = 5if number > 0: print('Positive number')print('Simple Learn') Positive number Simple Learn Positive numberSimple Learn IndentationError 2. 以下執行結果是什麼? number = -5if number > 0: print('Positive number')else: print('Negative number') print('Simple Learn') Positive number Negative number Positive numberSimple Learn Negative numberSimple Learn 3. 以下執行結果是什麼? number = -5if (number <= 0): if number == 0: print('Number is 0') else: print('Number is negative')else: print('Number is positive') Number is 0 Number is negative Number is positive IndentationError 4. 以下執行結果是什麼? if 20 < 30: print("Simple") print("Learn")print("is great") Simple Simpleis great SimpleLearn SimpleLearnis great 5. 以下執行結果是什麼? a = 33b = 100if b > a:print("b 比 a 大")print("a 比 b 大") b 比 a 大 a 比 b 大 b 比 a 大a 比 b 大 IndentationError 6. 以下執行結果是什麼? a = 11b = 11if b > a: print("b 比 a 大")elif a == b: print("a 和 b 相等") b 比 a 大 a 和 b 相等 b 比 a 大a 和 b 相等 IndentationError 7. 以下執行結果是什麼? a = 33b = 33if b >= a: print("b 比 a 大")elif a == b: print("a 和 b 相等")else: print("a 比 b 大") a 和 b 相等 b 比 a 大 a 比 b 大 IndentationError 8. 以下執行結果是什麼? if 51 < 5: print("Simple")elif 0 < 5: print("Learn")elif 0 < 3: print("is")else: print("great") 9. 以下執行結果是什麼? num = 33if num == 0: print(num, "is Green")elif num % 2 == 0: print(num, "is Yellow")else: print(num, "is Blue") 10. 以下執行結果是什麼? mark = 82if mark >= 60 and mark <= 100: if mark >= 90: print("You are the best!") elif mark >= 80: print("Well done!") elif mark >= 70: print("You can do better.") else: print("Pass.")elif mark > 100: print("This mark is too high.")elif mark < 0: print("This mark is too low.")else: print("Failed.") Time is Up! Time's up Share 0 FacebookTwitterPinterestEmail previous post P4B Quiz (12):字典資料型態介紹與使用 next post P4B Quiz (1):Python 介紹及相關開發環境簡介