Adaptive Practice
Python Revision — Functions
10 questions • Earn up to 104 XP • First attempt — go for 100%!
0
XP
0
Correct
x1
Combo
Question 1 of 10
⏱ 0:30
Easy
What is the correct syntax to define a function named 'calculate' in Python?
Easy
Which of the following is the correct way to call a function named 'greet' that takes no arguments?
Medium
What will be the output of the following code?
def add(x, y=5):
return x + y
print(add(3))
Easy
Which of the following statements about Python functions is TRUE?
Medium
What will be the output of the following code?
def func(a, b=2, c=3):
print(a, b, c)
func(1, c=4)
Medium
Consider the following code:
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
What is the output of print(factorial(4))?
Easy
Which of the following is NOT a valid way to define a function in Python?
Medium
What will be the output of the following code?
def modify(lst):
lst.append(4)
my_list = [1, 2, 3]
modify(my_list)
print(my_list)
Hard
What is the output of the following code?
def foo(x, y=5, z=10):
print(x, y, z)
foo(3, z=7)
Hard
Which of the following statements about Python function arguments is CORRECT?