🐍

Python Interview Questions

2 free questions to get you started. Unlock all sections (Normal, Code & Logic) with Pro.

Free sample — easy bait
1

What is the difference between a list and a tuple? Normal

List is mutable: you can add, remove, or change elements after creation; syntax [1, 2, 3]. Tuple is immutable: once created, you cannot change it; syntax (1, 2, 3). Tuples are slightly faster and use less memory; use them when the collection should not change (e.g. dictionary keys, return values that represent a fixed record).

2

Write a list comprehension that squares even numbers from 0 to 9. Code

[x**2 for x in range(10) if x % 2 == 0]

Result: [0, 4, 16, 36, 64]. You can also do [x**2 for x in range(0, 10, 2)] to iterate only evens.

Unlock all Python interview questions

35+ questions across Normal (conceptual), Code (write Python), and Logic (design & problem-solving).

Upgrade to Pro
Basics & data structures
3

*args and **kwargs — what are they and when do you use them? Normal

Unlock with Pro for the answer.

4

Write code to merge two dicts (Python 3.9+ and older way). Code

Unlock with Pro for the code.

5

When would you use a set vs a list for membership checks? Logic

Unlock with Pro for the answer.

Functions & decorators
6

What is a decorator? Give an example. Normal

Unlock with Pro for the answer.

7

Write a simple decorator that prints the time a function takes. Code

Unlock with Pro for the code.

8

Generators vs list comprehensions — when to use each? Logic

Unlock with Pro for the answer.

OOP & classes
9

@staticmethod vs @classmethod vs instance method? Normal

Unlock with Pro for the answer.

10

Implement a context manager that measures time (with statement). Code

Unlock with Pro for the code.

11

Explain MRO (method resolution order) in multiple inheritance. Logic

Unlock with Pro for the answer.

Data handling & pandas
12

What is the difference between merge, join, and concat in pandas? Normal

Unlock with Pro for the answer.

13

Write code to drop duplicate rows keeping the first occurrence. Code

Unlock with Pro for the code.

14

How would you optimize a pandas pipeline for a large CSV? Logic

Unlock with Pro for the answer.

Concurrency & patterns
15

What is the GIL? How does it affect threading vs multiprocessing? Normal

Unlock with Pro for the answer.

16

deepcopy vs shallow copy — when does it matter? Normal

Unlock with Pro for the answer.

17

Exception handling best practices (broad vs narrow, re-raise). Logic

Unlock with Pro for the answer.