Python Core Concepts - MCQ Practice Test

Test your Python core concepts knowledge with this MCQ practice quiz for interview preparation.

This is a practice MCQ quiz to test your Python core concepts knowledge for interview preparation. Answer all questions and submit to see your results.

Question 1
Which of the following data types is mutable in Python 3.12?
Question 2
What is the output of this code? def my_function(a, b=[]): b.append(a) return b print(my_function(1)) print(my_function(2)) print(my_function(3, [])) print(my_function(4))
Question 3
Which of the following correctly describes the purpose of the __init__ method in a Python 3.12 class?
Question 4
What will be the output of this code? x = 10 def outer(): x = 20 def inner(): nonlocal x x = 30 inner() print(x) outer() print(x)
Question 5
Which of the following is NOT a valid way to create a set in Python 3.12?
Question 6
In Python 3.12, what is the purpose of a generator function?
Question 7
Which of the following statements about Python's Global Interpreter Lock (GIL) (as of Python 3.12) is true?
Question 8
What is the correct way to handle a KeyError when trying to access a dictionary element in Python 3.12, providing a default value if the key is not found?