2. Programming

Functions And Modules — Quiz

Test your understanding of functions and modules with 5 practice questions.

Read the lesson first

Practice Questions

Question 1

When two Python modules A and B import each other at the top level causing a circular import error, which practice is recommended to resolve this issue?

Question 2

Which built-in attribute of a Python function holds its annotations such as parameter and return type hints?

Question 3

Consider the mutually recursive functions: def is_even(n): if n == 0: return True else: return is_odd(n-1) def is_odd(n): if n == 0: return False else: return is_even(n-1) What is the output of is_even(4)?

Question 4

Given the recursive implementation of the Euclidean algorithm: def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) What is the result of gcd(21, 6)?

Question 5

Which decorator from the functools module can be used to cache the results of function calls and avoid redundant computations in pure functions?