P4B Quiz (16):函式

by KC
0 comment

Welcome to your quiz -「 P4B Quiz (16):函式

Name
Email
1. 
以下執行結果是什麼?

def greet():
   print('Hello Python!')

greet()
print('Simple Learn')

2. 
以下執行結果是什麼?

def add_numbers(num1, num2):
   sum = num1 ** num2
   print("Sum: ",sum)

add_numbers(5, 3)

3. 
以下執行結果是什麼?

def MySquare(num):
   result = num * num + 10
   return result

print(MySquare(3))

4. 
以下執行結果是什麼?

def changeme(MyList):
   MyList.append([1, 2, 3])
   print(MyList)
   return

MyList = [10, 20, 30]
changeme(MyList)

5. 
以下執行結果是什麼?

def welcome_message(name):
   print(f"Welcome to {name} Tutorial")

welcome_message("Python")

6. 
以下執行結果是什麼?

def greet(name): 
   print ('Hello ', name)

greet('SimpleLearn' + ' is great')
greet(123)

7. 
以下執行結果是什麼?

def sum(a, b):
   return a * b

total=sum(10, 20)
print(total)

8. 
以下執行結果是什麼?

def sum(a, b): 
   return a + b

total=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 True

print(check(78))

error: Content is protected !!