Challenge - 5 Problems
Function Flow Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
โ Predict Output
intermediate2:00remaining
Output of nested function calls
What is the output of this Python code?
Python
def f(x): return x * 2 def g(y): return f(y) + 3 print(g(4))
Attempts:
2 left
๐ก Hint
Remember to follow the order of function calls and operations step by step.
โ Incorrect
Function g calls f with y=4, so f(4) returns 8. Then g adds 3, so 8 + 3 = 11.
โ Predict Output
intermediate2:00remaining
Value of variable after function call
What is the value of variable 'result' after running this code?
Python
def add_one(n): return n + 1 result = add_one(5)
Attempts:
2 left
๐ก Hint
Check what the function returns and what is assigned to 'result'.
โ Incorrect
The function adds 1 to 5, so result becomes 6.
โ Predict Output
advanced2:00remaining
Output with recursive function
What is the output of this recursive function call?
Python
def countdown(n): if n == 0: return 'Done' else: return str(n) + ' ' + countdown(n-1) print(countdown(3))
Attempts:
2 left
๐ก Hint
Trace the function calls from n=3 down to 0.
โ Incorrect
The function concatenates numbers down to 1 and then adds 'Done'.
โ Predict Output
advanced2:00remaining
Output with function modifying a list
What is printed after this code runs?
Python
def append_number(lst): lst.append(4) numbers = [1, 2, 3] append_number(numbers) print(numbers)
Attempts:
2 left
๐ก Hint
Think about how lists are passed to functions in Python.
โ Incorrect
The list is modified inside the function, so the original list has 4 appended.
โ Predict Output
expert2:00remaining
Output of function with default and keyword arguments
What is the output of this code?
Python
def greet(name, greeting='Hello'): return f"{greeting}, {name}!" print(greet('Alice')) print(greet('Bob', greeting='Hi'))
Attempts:
2 left
๐ก Hint
Check which greeting is used for each call.
โ Incorrect
First call uses default 'Hello', second call uses keyword argument 'Hi'.