LearnThatStack Ace your next interview
Backend Development

Python.

Start free Change topic Change
Practice · Questions

All questions

Showing of 59
Beginner 26
01

What is the difference between Python 2 and Python 3?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Python 3 is a backward-incompatible redesign of the language, so most Python 2 code needs changes to run on it. Python 2 reached its end of life on January 1, 2020, and new projects use Python 3.

The main differences are:

  • print became a function, so you write print("hello") instead of print "hello".
  • Strings are Unicode text by default, and raw bytes have their own bytes type.
  • The / operator does true division, so 5/2 returns 2.5 where Python 2 returned 2. Use // for floor division.
  • range() returns a lazy range object instead of a list, and map() and filter() return iterators.
  • raw_input() was renamed to input(), which always returns a string.
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

What is PEP 8?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

PEP 8 is the official style guide for Python code. It sets shared conventions so that code from different people looks the same. Its main rules are:

  • Indent with 4 spaces per level.
  • Keep lines to a maximum of 79 characters.
  • Name variables and functions in snake_case, classes in CapWords, and constants in UPPER_CASE.
  • Group imports in order: standard library, third-party packages, then your own modules.
  • Put single spaces around operators and after commas.
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

Explain Python's indentation and why it matters.

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Python uses indentation to mark code blocks, where languages such as C and Java use braces {}. All lines in one block start at the same indentation level, and a deeper level opens a nested block. The parser reads this whitespace, so the layout is part of the syntax.

if x > 0:
    print("Positive")  # 4 spaces indentation
    if x > 10:
        print("Greater than 10")  # 8 spaces indentation
else:
    print("Non-positive")

It matters for two reasons. It gives every Python file the same consistent shape, which makes code easier to read. It also means a wrong indent either moves a line into a different block or stops the file from running. Incorrect indentation raises IndentationError, and mixing tabs and spaces inconsistently raises TabError. PEP 8 recommends four spaces per level.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

What are Python keywords and identifiers?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Keywords are reserved words with a fixed meaning in the language, such as if, def and class. You cannot use them as names. Identifiers are the names you choose for variables, functions and classes. An identifier follows these rules:

  • It starts with a letter or an underscore.
  • It contains only letters, digits and underscores.
  • It is case-sensitive, so count and Count are different names.
  • It cannot be a keyword.
# Valid identifiers
variable_name = 10
_private_var = 20
ClassName = "example"

# Invalid identifiers
# 123variable = 10  # Cannot start with digit
# class = "test"    # Cannot use keyword

The keyword module lists every keyword in keyword.kwlist. A few names, such as match and case, are soft keywords, reserved only inside the statements that use them.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

Explain Python's built-in data types.

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Python's most common built-in data types, grouped by the kind of value they hold, are:

  • Numeric: int, float and complex.
  • Sequence: str, list and tuple.
  • Set: set and frozenset.
  • Mapping: dict.
  • Boolean: bool, with the values True and False.
  • None: NoneType, whose only value is None.

Python is dynamically typed, so a variable has no fixed type, and type(value) tells you the type of the value it holds. The types also differ in mutability. Lists, dicts and sets can change in place, while numbers, strings and tuples cannot.

integer = 42
floating = 3.14
string = "Hello"
boolean = True
none_value = None
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

What is the difference between list and tuple?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A list is mutable, so you can add, remove and change its items after you create it. A tuple is immutable, so its contents are fixed once it exists. Use a list for a collection that grows or changes, and a tuple for a fixed group of values, such as a pair of coordinates.

List Tuple
Mutable Immutable
Uses square brackets [] Uses parentheses ()
Slower performance Faster performance
More memory usage Less memory usage

A tuple is a little faster and smaller because Python allocates it once at a fixed size. A list keeps spare room so appends stay cheap. Because a tuple is immutable, it is also hashable when all its items are, so it can be a dictionary key or a set member. A list cannot.

# List - mutable
my_list = [1, 2, 3]
my_list[0] = 10  # Works

# Tuple - immutable
my_tuple = (1, 2, 3)
# my_tuple[0] = 10  # TypeError
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

Explain Python dictionaries and their characteristics.

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A dictionary is a mutable mapping from unique keys to values. It is built on a hash table, so looking up a value by its key takes O(1) time on average. Its main characteristics are:

  • Keys must be unique and hashable, which means their hash value never changes. Strings, numbers and tuples of hashable items work as keys, but lists do not.
  • Values can be any object.
  • Since Python 3.7, a dictionary keeps its items in insertion order.
  • d[key] raises KeyError for a missing key, while d.get(key) returns None or a default you pass.
student = {
    "name": "John",
    "age": 25,
    "grades": [85, 90, 78]
}

# Accessing values
print(student["name"])  # John
print(student.get("age"))  # 25

# Adding/updating
student["email"] = "john@email.com"
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

08

Explain the different types of loops in Python.

Part of Pro
09

What are break, continue, and pass statements?

Part of Pro
10

Explain conditional statements in Python.

Part of Pro
11

How do you define and call functions in Python?

Part of Pro
12

Explain classes and objects in Python.

Part of Pro
13

Explain exception handling in Python.

Part of Pro
14

What is the difference between except and finally?

Part of Pro
15

What is the difference between modules and packages?

Part of Pro
16

Explain different ways to import modules.

Part of Pro
17

What is the difference between range() and xrange()?

Part of Pro
18

What are Python's built-in functions you should know?

Part of Pro
19

Explain Python's __name__ == "__main__" idiom.

Part of Pro
20

Explain Python's file handling modes.

Part of Pro
21

What is the difference between is and == with examples?

Part of Pro Visual
22

What is the difference between mutable and immutable types in Python?

Part of Pro
23

Explain list comprehensions in Python.

Part of Pro
24

What is the difference between local and global variables?

Part of Pro
25

Explain lambda functions in Python.

Part of Pro
26

What is inheritance and how is it implemented?

Part of Pro
Intermediate 29
27

Explain different types of function arguments.

Part of Pro
28

Explain method overriding and method overloading.

Part of Pro
29

What are class variables vs instance variables?

Part of Pro Visual
30

Explain encapsulation and access modifiers.

Part of Pro
31

How do you raise custom exceptions?

Part of Pro
32

What is __init__.py and what is its purpose?

Part of Pro
33

What are decorators and how do they work?

Part of Pro Visual
34

Explain generators and the yield keyword.

Part of Pro Visual
35

Explain context managers and the with statement.

Part of Pro
36

Explain the *args and **kwargs concepts.

Part of Pro
37

How does Python manage memory?

Part of Pro
38

What is the difference between del and garbage collection?

Part of Pro Visual
39

How can you improve Python performance?

Part of Pro
40

Explain the difference between multiprocessing and multithreading.

Part of Pro
41

What is unit testing and how is it implemented in Python?

Part of Pro
42

Explain debugging techniques in Python.

Part of Pro
43

What is the difference between assert and exception handling?

Part of Pro
44

What is the difference between shallow copy and deep copy?

Part of Pro Visual
45

What are dataclasses and how do they work?

Part of Pro
46

Explain the super() function.

Part of Pro Visual
47

What are Python's special or magic methods?

Part of Pro
48

What are Python virtual environments and why are they important?

Part of Pro
49

Why are mutable default arguments dangerous in Python?

Part of Pro Visual
50

What is the difference between instance methods, class methods and static methods?

Part of Pro
51

What is the difference between an iterable and an iterator?

Part of Pro
52

What is a closure in Python?

Part of Pro Visual
53

Does Python pass arguments by value or by reference?

Part of Pro Visual
54

What happens when you run a Python program?

Part of Pro
55

Explain the concept of monkey patching.

Part of Pro
Expert 4
56

What are metaclasses in Python?

Part of Pro Visual
57

Explain Python's memory optimization techniques.

Part of Pro
58

What is the Global Interpreter Lock (GIL)?

Part of Pro Visual
59

Explain Python's async/await and asynchronous programming.

Part of Pro Visual

No matches

Try a different filter or search term.

Know someone prepping for Python? Send them this set.
Quick recap

Python in pictures.

A quick recap of Python in 31 short animated pictures, one idea at a time. About 8 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.

Pro The first chapter is free to play. The other 27 pictures come with Pro.

Get Pro · $10/mo
Pro · $10/mo

52 of 59 Python answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git