P4B Quiz (16):函式 by KC 2023-03-26 written by KC 2023-03-26 0 comment Welcome to your quiz -「 P4B Quiz (16):函式」 Name Email 1. 以下執行結果是什麼? def greet(): print('Hello Python!')greet()print('Simple Learn') Hello Python! Simple Learn Hello Python! Simple Learn 2. 以下執行結果是什麼? def add_numbers(num1, num2): sum = num1 ** num2 print("Sum: ",sum)add_numbers(5, 3) 5 3 15 125 3. 以下執行結果是什麼? def MySquare(num): result = num * num + 10 return resultprint(MySquare(3)) 3 9 10 19 4. 以下執行結果是什麼? def changeme(MyList): MyList.append([1, 2, 3]) print(MyList) returnMyList = [10, 20, 30]changeme(MyList) [10, 20, 30] [1, 2, 3] [10, 20, 30, [1, 2, 3]] [10, 20, 30, 1, 2, 3] 5. 以下執行結果是什麼? def welcome_message(name): print(f"Welcome to {name} Tutorial")welcome_message("Python") Python Welcome to name Tutorial Welcome to {name} Tutorial Welcome to Python Tutorial 6. 以下執行結果是什麼? def greet(name): print ('Hello ', name)greet('SimpleLearn' + ' is great')greet(123) Hello SimpleLearn is greatHello 123 Hello SimpleLearnHello is greatHello 123 Hello SimpleLearn is great TypeError 7. 以下執行結果是什麼? def sum(a, b): return a * btotal=sum(10, 20)print(total) 8. 以下執行結果是什麼? def sum(a, b): return a + btotal=sum(5, sum(10, 20))print(total) 9. 以下執行結果是什麼? def check(x): if (x % 3 == 0): print("A") else: print("B")check(131) 10. 以下執行結果是什麼? def check(n): if n in [2, 3]: return True if (n == 1) or (n % 2 == 0): return False r = 3 while r * r <= n: if n % r == 0: return False r += 2 return Trueprint(check(78)) Time is Up! Time's up Share 0 FacebookTwitterPinterestEmail previous post P4B Quiz (15):迴圈控制 – for loops