Guess the Output
24 short Python programs, 20 seconds each: predict exactly what the code prints.
How to score well
The scoring rewards speed and consistency: 100 points for a correct answer, up to 100 more for answering quickly, and a growing bonus for each answer in a streak. A wrong answer or a timeout costs a life and resets the streak, so a careful run of 24 beats a fast run that dies at question eight.
The quickest way to improve is to stop guessing and start evaluating. Read the snippet line by line and say out loud what each name holds after that line. Most of the questions turn on one precise rule — which value an operator produces, whether a method returns a new object or mutates in place, where a slice stops.
The traps this game drills
- Mutation vs return.
list.sort()returnsNone;sorted(list)returns a new list. The same split catchesstr.upper(), which cannot change a string at all. - Aliasing.
b = agives a second name for one list, not a copy. - Integer division and precedence.
7 // 2,-7 // 2and2 ** 3 ** 2all surprise people once. - Truthiness.
bool("False")isTrue; only empty values are falsy. - Floating point.
0.1 + 0.2 == 0.3isFalsein every language with binary floats. - Mutable default arguments. The most-asked Python interview gotcha there is.
Topics in the current deck: Booleans, Comprehensions, Dicts, Floats, Formatting, Functions, Lists, Loops, Numbers, Operators, Sets, Slicing, Strings, Tuples.
Where to read up on a question you missed
- Numbers and operators — division, precedence, modulo.
- Strings — slicing, methods, f-strings.
- Lists — mutability, copying, sorting.
- Dictionaries and sets —
get(), merging, uniqueness. - Functions — default arguments and return values.
Frequently asked questions
How does the Guess the Output game work?
You see a short Python program and four possible outputs. Pick the right one before the 20-second timer runs out. Correct answers earn points plus a time bonus and a streak multiplier; three wrong answers ends the run.
Are the answers really correct?
Yes — every one of the 24 snippets is executed on real CPython whenever this site is built, and the build fails if a stated answer does not match the actual output.
What topics are covered?
Operators and integer division, strings and slicing, lists and mutability, dictionaries, sets, booleans, f-strings, comprehensions, loop else, and the classic traps such as mutable default arguments and floating-point comparison.
Is this good practice for a Python interview?
Very. 'What does this print?' is a standard screening question, and the gotchas here — sort() returning None, aliasing a list, 0.1 + 0.2, mutable defaults — come up constantly.
Do I need to install anything?
No. The quiz is pure HTML and JavaScript; it starts instantly and works offline once the page has loaded.