← All interview questions

Skill Zuno · skillzunos.com · Fullstack

Python interview questions

Prepare for Python interviews on Skill Zuno. This practice book covers Python interview questions across New, Easy, Medium, Hard, and Diff levels so you can work through real interview-style problems on skillzunos.com.

Open Python on Skill Zuno

Also see the Python tutorial.

Python is a high-level, dynamically typed language known for readable syntax and a large standard library. It is used for web back ends, scripting, automation, data science and machine learning. Python interviews test data structures, mutability, comprehensions, generators, decorators and the GIL.

Sample Python interview questions

What is the difference between a list and a tuple?

A list is mutable and a tuple is immutable. Because tuples cannot change they are hashable when their items are, so they can be dict keys or set members, and they use slightly less memory.

Why should you not use a mutable default argument?

Defaults are evaluated once, when the function is defined. def f(items=[]) shares one list across every call, so items appended in one call appear in the next. Use items=None and create the list inside the function.

What is a generator?

A generator is a function that uses yield to produce values lazily, one at a time, keeping its state between calls. It suits large or infinite sequences because the whole result never sits in memory.

What is the GIL?

The Global Interpreter Lock in CPython lets only one thread run Python bytecode at a time. Threads still help with I/O-bound work, but CPU-bound work needs multiprocessing or native extensions that release the GIL.

What does a decorator do?

A decorator is a function that takes a function and returns a replacement, usually a wrapper that adds behaviour such as logging, caching or access checks. @decorator above a def is shorthand for func = decorator(func).

What you can practice

  • Python interview questions for beginners and experienced developers
  • Level-based practice: New, Easy, Medium, Hard, and Diff
  • Fullstack topics alongside Python on skillzunos.com

More Fullstack interview questions

All interview questions