Skip to content
codinganthem

Python skill check

Test your Python: mutability, comprehensions, closures, generators, classes, and the standard library, including snippets where you predict exactly what gets printed.

15

Questions

14 min

Timer can't pause

Multiple choice

Python 3.12

Choose a level

Question type

About 40% code reading

Topics

  • Data types
  • Lists, dicts, and sets
  • Comprehensions
  • Functions and closures
  • Generators and iterators
  • Classes
  • Exceptions
  • Standard library

Do

Use scratch paper or a notepad to work things out. Skip a question and come back to it later.

Don't

Run the code or look up answers during the check. Open the check in more than one tab or window.

Easy · Mixed · 15 questions · 14 min

By starting, you agree to the Terms and Privacy Policy.

Start practice

Practice checks each answer as you go, with an explanation. The exam is checked when you submit; 9 of 15 passes and earns a certificate.

Checking your levels…

Certificates come from the certified exam: pass with 9 of 15 while signed in. View a sample certificate.

Sample Python questions with answers

These are never used in a check, so seeing their answers here won't give anything away.

  1. Question 1 · Easy · Lists, dicts, and sets

    Which Python object can be used as a key in a standard built-in dict?
    1. A.A tuple containing only strings and integers
    2. B.A list containing only integers
    3. C.A set containing only strings
    4. D.A dictionary whose values are all immutable
    Show answer

    A. A tuple containing only strings and integers

    Dictionary keys must be hashable. Tuples that contain only hashable elements (like strings and integers) are immutable and hashable, whereas lists, sets, and dicts are mutable and unhashable.
  2. Question 2 · Easy · Exceptions

    In a Python try-except-else-finally construct, under what condition does the else block execute?
    1. A.Only if the try block raises an unhandled exception that bubbles up.
    2. B.Only when at least one exception was caught and handled in an except block.
    3. C.Only when the try block finishes without any exception being raised.
    4. D.Whenever the finally block completes without an error.
    Show answer

    C. Only when the try block finishes without any exception being raised.

    The else clause in a try block runs if and only if the control flow leaves the try block without raising any exceptions.
  3. Question 3 · Moderate · Functions and closures

    In Python, default parameter values for functions are evaluated when:
    1. A.The function definition statement executes.
    2. B.The function is called without that argument provided.
    3. C.The module containing the function is compiled into bytecode (.pyc).
    4. D.The function is called for the first time only.
    Show answer

    A. The function definition statement executes.

    Default argument expressions in Python are evaluated once at definition time when the def statement executes, which is why mutable objects used as defaults persist across subsequent calls.
  4. Question 4 · Advanced · Generators and iterators

    What occurs when the .close() method is called on an active Python generator that yields within a try block whose finally block contains another yield expression?
    1. A.The generator closes silently, discarding the value yielded from the finally block.
    2. B.A RuntimeError is raised at the caller's call site.
    3. C.A GeneratorExit exception is propagated directly to the caller.
    4. D.The generator yields the value from the finally block and suspends execution normally.
    Show answer

    B. A RuntimeError is raised at the caller's call site.

    When .close() raises GeneratorExit inside a generator, the generator must either exit cleanly or allow GeneratorExit to propagate. If it catches GeneratorExit or executes a finally clause that attempts to yield another value, Python raises a 'RuntimeError: generator ignored GeneratorExit'.

How scoring and certificates work

  • Each check has 15 multiple-choice questions with one correct answer, and one timer for the whole check. A question you leave unanswered scores nothing.
  • Practice is free without an account and shows whether each answer is right as you go, with an explanation.
  • The certified exam is scored when you submit. 60% passes, which is 9 of 15. Easy unlocks Moderate, and Moderate unlocks Advanced.
  • Passing the exam while signed in earns a free certificate, valid for one year, with its own verification page. See a sample certificate.

Free tools for Python: JSON Formatter, Regex Tester, CSV to JSON