2. Programming Fundamentals

Functions And Modules — Quiz

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

Read the lesson first

Practice Questions

Question 1

Which of the following best describes the concept of 'pass by object reference' in Python when passing mutable objects to functions?

Question 2

Consider a Python function process_list(my_list) that appends an element to my_list. If my_list is initialized as [1, 2, 3] before the function call, what will be the value of my_list after process_list(my_list) is executed, assuming the function appends 4?

Question 3

Which of the following scenarios is most likely to lead to a 'circular import' error in Python, and how can it typically be resolved?

Question 4

Consider a Python function calculate_sum(*args) that uses *args to accept an arbitrary number of positional arguments. If the function is called as calculate_sum(1, 2, 3, 4), what type of object will args be inside the function, and what will be its value?

Question 5

A Python module data_utils.py contains a function process_data(data) and a global constant BATCH_SIZE = 100. Another script imports data_utils and then attempts to modify data_utils.BATCH_SIZE to 200. What is the implication of this modification for other parts of the script or other modules that also import data_utils?
Functions And Modules Quiz — Computer Science | A-Warded