♻️
Logic Building - Phase 3: Recursion
Test your recursive thinking and ability to solve problems using self-referencing functions
35 questions•4 pages•~53 min
Use this quiz track to strengthen recall, speed, and exam-style decision making. Attempt one page first, review explanations, and then re-attempt incorrect questions without notes.
A good scoring strategy is to mark uncertain questions, finish known ones quickly, and return with elimination logic. This improves accuracy while keeping momentum under time constraints.
Progress: 0 / 350%
Page 2 of 4 • Questions 11-20 of 35
Q11hard
What is the base case in this recursive function? def gcd(a, b): if b == 0: return a return gcd(b, a % b)
Q12hard
What will be printed? def reverse_string(s): if len(s) <= 1: return s return reverse_string(s[1:]) + s[0] print(reverse_string("abc"))
Q13easy
What is the result of sum_natural(10)?
def sum_natural(n):
if n == 0:
return 0
return n + sum_natural(n-1)Q14easy
What will be printed? def print_stars(n): if n == 0: return print("*", end="") print_stars(n-1) print_stars(5)
Q15hard
What is the key difference between tail recursion and head recursion?
Q16hard
What will be printed? def binary(n): if n == 0: return "0" if n == 1: return "1" return binary(n // 2) + str(n % 2) print(binary(10))
Q17medium
What is the result of fibonacci(6)?
def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)Q18easy
What will be printed? def print_n_to_1(n): if n == 0: return print(n, end=" ") print_n_to_1(n-1) print_n_to_1(4)
Q19easy
What does this recursive function calculate? def product(n): if n == 1: return 1 return n * product(n-1)
Q20hard
What is the output?
def is_palindrome(s):
if len(s) <= 1:
return True
if s[0] != s[-1]:
return False
return is_palindrome(s[1:-1])
print(is_palindrome("racecar"))