Interview Q&A Python All Levels

Python MCQ — Basics to Advanced

30 multiple-choice questions covering Python syntax, data structures, OOP, decorators, generators, exceptions, and the standard library.

7 min read 30 Questions
1 What is the output of `print(type([]))` in Python?
2 Which of the following is an immutable data type in Python?
3 What does `len({'a': 1, 'b': 2, 'c': 3})` return?
4 What is the output of `[1, 2, 3][1:2]`?
5 Which keyword is used to define a generator function in Python?
6 What will `bool([])` evaluate to?
7 What does `*args` in a function definition collect?
8 What is the result of `10 // 3` in Python?
9 Which of these creates a shallow copy of a list `lst`?
10 What is the output of `print('abc'[-1])`?
11 Which decorator is used to define a class method that receives the class as the first argument?
12 What does the `__init__` method do in a Python class?
13 What is the GIL in Python?
14 Which module provides the `deepcopy` function?
15 What is the output of `list(range(0, 10, 3))`?
16 What will `{1, 2, 3} & {2, 3, 4}` return?
17 What does `functools.wraps` do when writing a decorator?
18 Which of these is the correct way to open a file safely in Python?
19 What is the output of `print(2 ** 3 ** 2)`?
20 What does `enumerate(['a', 'b', 'c'])` return?
21 What is the difference between `is` and `==` in Python?
22 What happens when you call `next()` on an exhausted generator?
23 Which built-in function converts a string to an integer?
24 What does the `@property` decorator do?
25 What is the purpose of `__slots__` in a Python class?
26 Which module would you use for asynchronous HTTP requests in Python?
27 What does `dict.get('key', 'default')` do when the key doesn't exist?
28 What is a `lambda` function in Python?
29 What does `Counter('aabbbcc').most_common(2)` return?
30 Which of the following correctly uses `asyncio.gather()`?

Add More Questions to This Guide

Know a question that should be here? Share it and help the community!

Open Google Form