Home › Python Output Practice

Python output prediction practice

🔮 24 output questionsFree, no loginInterview-style

How this archive works

Every card is a "predict the output" question — the exact format used in Python interviews and university exams. The featured questions below run right on the page: type your predicted output, check it, and get a line-by-line trace of why. The rest open in PyDebug's interactive editor, which verifies your prediction automatically.

New to the format? Start with the output-prediction strategy guide, then come back and drill.

Filter

Answer on this page

Answer in the interactive editor

break vs continue

Interactive — predict in the editor, get checked instantly.

loops medium

Loop variable after the loop ends

Interactive — predict in the editor, get checked instantly.

loops medium

else clause on a for loop

Interactive — predict in the editor, get checked instantly.

loops medium

enumerate with a start value

Interactive — predict in the editor, get checked instantly.

loops easy

List multiplication

Interactive — predict in the editor, get checked instantly.

lists medium

Negative indexing

Interactive — predict in the editor, get checked instantly.

lists easy

List copy vs reference

Interactive — predict in the editor, get checked instantly.

lists easy

Slicing excludes the end index

Interactive — predict in the editor, get checked instantly.

lists easy

String repetition and length

Interactive — predict in the editor, get checked instantly.

strings easy

String multiplication and indexing

Interactive — predict in the editor, get checked instantly.

strings easy

String multiplication in a loop

Interactive — predict in the editor, get checked instantly.

strings medium

Default parameter values

Interactive — predict in the editor, get checked instantly.

functions medium

Function returning nothing

Interactive — predict in the editor, get checked instantly.

functions easy

Chained assignment

Interactive — predict in the editor, get checked instantly.

functions easy

Mutable default argument trap

Interactive — predict in the editor, get checked instantly.

functions medium

dict.get() with a default

Interactive — predict in the editor, get checked instantly.

dictionaries medium

Dictionary keys must be unique

Interactive — predict in the editor, get checked instantly.

dictionaries medium

Tuple immutability

Interactive — predict in the editor, get checked instantly.

tuples easy

Sets remove duplicates

Interactive — predict in the editor, get checked instantly.

sets easy

try/except/else flow

Interactive — predict in the editor, get checked instantly.

exceptions medium

Class variable shared across instances

Interactive — predict in the editor, get checked instantly.

oop medium

Why output prediction makes you a better debugger

Debugging is prediction in reverse: you read code that already misbehaved and reconstruct what it must have done. Practising forward prediction — stating exactly what each line prints before running it — builds the same mental interpreter. The learners who get fast at these questions are the same ones who stop needing twenty print statements to find a bug.

Struggling with a specific crash instead? The Python error explainer decodes the six most common exceptions, and the tricks collection catalogues the classic traps.