Python practice
Every Python exercise, built from a topic you can open beside it.
139 exercises runs offline
All tracks Python 139 JavaScript 184 TypeScript 76 Go 106 Rust 75 Java 81 Kotlin 66 C++ 92 C# 88 Swift 68 PHP 69 Frontend 82 Backend 139 Architecture and system design 25 DevOps and cloud 15 Data and databases 5 Data science 31 AI and LLM engineering 75 Security 26 Game development 26 Coding in the AI era 101 CS foundations 164
level
py Quiz new In def route(path, /, version, *parts, strict=True, **metadata), which classification is … Collect, unpack, and forward variable arguments without hiding a function's contract or accepting misspelled options. py Quiz new What happens when capture is defined as def capture(**metadata) and called as capture(**{… Collect, unpack, and forward variable arguments without hiding a function's contract or accepting misspelled options. py Predict the output new What does this program print? Collect, unpack, and forward variable arguments without hiding a function's contract or accepting misspelled options. py Review AI code new Review a generated retry wrapper Collect, unpack, and forward variable arguments without hiding a function's contract or accepting misspelled options. py Spot the bug new Spot the bug in connection options Collect, unpack, and forward variable arguments without hiding a function's contract or accepting misspelled options. py Predict the output new In what order does this program print its four lines? Organize I/O with coroutines, tasks, and structured concurrency while handling timeouts, cancellation, blocking calls, and concurrency limits. py Review AI code new Review a generated async URL fetcher Organize I/O with coroutines, tasks, and structured concurrency while handling timeouts, cancellation, blocking calls, and concurrency limits. py Spot the bug new Spot the bug in the async job batch Organize I/O with coroutines, tasks, and structured concurrency while handling timeouts, cancellation, blocking calls, and concurrency limits. py Quiz new What normally happens when one child in an active TaskGroup raises ValueError? Organize I/O with coroutines, tasks, and structured concurrency while handling timeouts, cancellation, blocking calls, and concurrency limits. py Quiz new Where should code catch the TimeoutError produced by asyncio.timeout()? Organize I/O with coroutines, tasks, and structured concurrency while handling timeouts, cancellation, blocking calls, and concurrency limits. py Quiz new What does [n * n for n in range(6) if n % 2] produce? Quiz py Quiz new Which pair is produced by (7 // 3, 7 % 3)? Quiz py Fill in new Enter the Python expression that creates an empty set Fill in py Quiz new When does an else clause attached to a for loop run? Quiz py Quiz new After a = [1], b = a, and b.append(2), what is a? Quiz py Fill in new In range(2, 5), enter the first excluded stop value Fill in py Quiz new What is bool("False")? Quiz py Fill in new Name the exception raised by {[]}, where a list is used as a set element Fill in py Quiz new A function appends to a default parameter items=[]. What happens across calls that omit i… Quiz py Fill in new Which keyword lets an inner function rebind a name in its nearest enclosing function scop… Fill in py Fill in new Name the exception raised when next() advances an exhausted iterator Fill in py Quiz new What does calling a generator function do before next() or iteration begins? Quiz py Quiz new What does [f() for f in [lambda: i for i in range(3)]] produce? Quiz py Quiz new For def render(source, /, *, compact=False), which call is valid? Quiz py Fill in new Enter the four-letter name for Python’s Local, Enclosing, Global, Built-in lookup order Fill in py Quiz new Inside def collect(*values, **labels), which container types are values and labels? Quiz py Quiz new May a method decorated with @abstractmethod contain a concrete implementation? Quiz py Fill in new Name the exception raised when a subclass still has an unimplemented abstract method and … Fill in py Quiz new Two instances initially read the class attribute status = "new". What does first.status =… Quiz py Quiz new For an ordinary instance method, what does Python do when code calls account.deposit(10)? Quiz py Fill in new Name the magic method that defines an object’s developer-oriented representation Fill in py Quiz new A frozen dataclass has a field values: list[int]. Which statement is correct? Quiz py Fill in new Which dataclasses field() argument creates a fresh list for every instance? Fill in py Quiz new In cooperative multiple inheritance, which implementation does zero-argument super() sear… Quiz py Quiz new In with manager as resource, where does resource come from? Quiz py Fill in new Which boolean value returned by __exit__ suppresses an exception from the with block? Fill in py Quiz new A logger accepts DEBUG and above, but its only handler is set to WARNING. What happens to… Quiz py Quiz new Which statement correctly distinguishes json.dumps() from json.dump()? Quiz py Quiz new What does pytest do if code inside with pytest.raises(ValueError) completes normally? Quiz py Fill in new By default, what SystemExit status does argparse use for an invalid value such as --count… Fill in py Quiz new What does Path("reports") / "daily.json" do? Quiz py Quiz new What happens when Path("notes.txt").write_text("new") targets an existing file? Quiz py Fill in new Which typing construct captures a callable’s complete parameter signature so a decorator … Fill in py Quiz new What does calling an async def function return before it is awaited? Quiz py Quiz new Which statement about concurrent.futures is correct? Quiz py Quiz new What happens by default when a function annotated def total(count: int) is called with "3… Quiz py Fill in new Name the threading primitive commonly used to make a multi-step shared-state update mutua… Fill in py Fill in new Name the typing construct that describes structural subtyping without requiring explicit … Fill in py Quiz new What normally happens when one child in an active asyncio.TaskGroup raises ValueError? Quiz py Quiz new On a standard GIL-enabled CPython build, which default choice best matches the workload? Quiz py Quiz new What does a Python closure capture for a free variable? Closures let functions retain access to enclosing bindings; understand cells, nonlocal, and late binding to keep state and callbacks correct. py Quiz new An inner function executes count += 1, but count is bound only in the enclosing function.… Closures let functions retain access to enclosing bindings; understand cells, nonlocal, and late binding to keep state and callbacks correct. py Predict the output new What does this program print? Closures let functions retain access to enclosing bindings; understand cells, nonlocal, and late binding to keep state and callbacks correct. py Review AI code new Review generated retry handlers Closures let functions retain access to enclosing bindings; understand cells, nonlocal, and late binding to keep state and callbacks correct. py Quiz new What must a context manager do if __enter__() fails after acquiring its first subresource? Context managers bind resource acquisition and required cleanup to a with block, including exception flow, generator wrappers, dynamic stacks, and async release. py Quiz new Why should dynamic acquisition call stack.enter_context() immediately for each resource? Context managers bind resource acquisition and required cleanup to a with block, including exception flow, generator wrappers, dynamic stacks, and async release. py Predict the output new What does this program print? Context managers bind resource acquisition and required cleanup to a with block, including exception flow, generator wrappers, dynamic stacks, and async release. py Review AI code new Review a generated batch publisher Context managers bind resource acquisition and required cleanup to a with block, including exception flow, generator wrappers, dynamic stacks, and async release. py Spot the bug new Spot the bug in the report context manager Context managers bind resource acquisition and required cleanup to a with block, including exception flow, generator wrappers, dynamic stacks, and async release. py Quiz new What is the value of result after result = [] or "fallback"? Use branches, iteration, loop control, and structural pattern matching precisely while avoiding nontermination and misleading truth tests. py Quiz new Inside match status, what does case READY: normally mean? Use branches, iteration, loop control, and structural pattern matching precisely while avoiding nontermination and misleading truth tests. py Predict the output new What does this program print? Use branches, iteration, loop control, and structural pattern matching precisely while avoiding nontermination and misleading truth tests. py Review AI code new Review a generated command dispatcher Use branches, iteration, loop control, and structural pattern matching precisely while avoiding nontermination and misleading truth tests. py Spot the bug new Spot the bug in archived-record removal Use branches, iteration, loop control, and structural pattern matching precisely while avoiding nontermination and misleading truth tests. py Quiz new A function will only add and remove keys in a dictionary; it will not mutate any values. … How Python copies object graphs, preserves shared references, handles cycles, and supports field replacement. py Predict the output new What does this program print? How Python copies object graphs, preserves shared references, handles cycles, and supports field replacement. py Quiz new After copy.replace(record, status="sent"), what should you assume about an unchanged muta… How Python copies object graphs, preserves shared references, handles cycles, and supports field replacement. py Review AI code new Review generated work-order copier How Python copies object graphs, preserves shared references, handles cycles, and supports field replacement. py Spot the bug new Spot the bug in the deep-copy hook How Python copies object graphs, preserves shared references, handles cycles, and supports field replacement. py Quiz new Why should a transparent decorator for async def usually return an async def wrapper? Decorators replace function or class bindings at definition time; preserve contracts across wrapping, stacking, metadata, typing, and async code. py Quiz new For @retry_on(ConnectionError, attempts=3), what must retry_on(...) return? Decorators replace function or class bindings at definition time; preserve contracts across wrapping, stacking, metadata, typing, and async code. py Predict the output new What does this program print? Decorators replace function or class bindings at definition time; preserve contracts across wrapping, stacking, metadata, typing, and async code. py Review AI code new Review a generated payment decorator Decorators replace function or class bindings at definition time; preserve contracts across wrapping, stacking, metadata, typing, and async code. py Spot the bug new Spot the bug in the decorator wrapper Decorators replace function or class bindings at definition time; preserve contracts across wrapping, stacking, metadata, typing, and async code. py Quiz new What does functools.wraps() guarantee for a wrapper? Decorators replace function or class bindings at definition time; preserve contracts across wrapping, stacking, metadata, typing, and async code. py Quiz new Which signature makes order_id positional-only and timeout keyword-only? Functions bind inputs to parameters, run code in a local scope, and return results; clear call conventions turn that behavior into a stable interface. py Predict the output new What two lines does this program print? Functions bind inputs to parameters, run code in a local scope, and return results; clear call conventions turn that behavior into a stable interface. py Predict the output new What does this program print? Functions bind inputs to parameters, run code in a local scope, and return results; clear call conventions turn that behavior into a stable interface. py Review AI code new Review generated order pricer Functions bind inputs to parameters, run code in a local scope, and return results; clear call conventions turn that behavior into a stable interface. py Spot the bug new Spot the bug in the mutable default Functions bind inputs to parameters, run code in a local scope, and return results; clear call conventions turn that behavior into a stable interface. py Predict the output new What does this program print? Use functools to bind call arguments, preserve wrapper metadata, reduce iterables, and adapt comparison protocols without breaking interface contracts. py Predict the output new What are the two output lines? Use functools to bind call arguments, preserve wrapper metadata, reduce iterables, and adapt comparison protocols without breaking interface contracts. py Review AI code new Review a generated audited total Use functools to bind call arguments, preserve wrapper metadata, reduce iterables, and adapt comparison protocols without breaking interface contracts. py Spot the bug new Spot the bug in the comparator Use functools to bind call arguments, preserve wrapper metadata, reduce iterables, and adapt comparison protocols without breaking interface contracts. py Quiz new Which guarantee does functools.wraps() provide? Use functools to bind call arguments, preserve wrapper metadata, reduce iterables, and adapt comparison protocols without breaking interface contracts. py Quiz new Which statement correctly distinguishes an iterable from an iterator? Understand Python's iteration protocol, lazy execution, yield, generator delegation, and resource cleanup to build predictable single-pass data flows. py Predict the output new Which lines appear, and in what order? Understand Python's iteration protocol, lazy execution, yield, generator delegation, and resource cleanup to build predictable single-pass data flows. py Predict the output new What does this program print? Understand Python's iteration protocol, lazy execution, yield, generator delegation, and resource cleanup to build predictable single-pass data flows. py Review AI code new Review a generated lazy order reader Understand Python's iteration protocol, lazy execution, yield, generator delegation, and resource cleanup to build predictable single-pass data flows. py Spot the bug new Spot the bug in the file-line generator Understand Python's iteration protocol, lazy execution, yield, generator delegation, and resource cleanup to build predictable single-pass data flows. py Quiz new What happens when StopIteration escapes directly from a generator function body in Python… Understand Python's iteration protocol, lazy execution, yield, generator delegation, and resource cleanup to build predictable single-pass data flows. py Quiz new After values = [parsed for raw in rows if (parsed := parse(raw)) is not None] succeeds, w… List comprehensions express iterable transformation and filtering in one expression; learn clause order, scope, evaluation, and when a loop is clearer. py Quiz new Which loop has the same order as [(team, member) for team in teams for member in team.mem… List comprehensions express iterable transformation and filtering in one expression; learn clause order, scope, evaluation, and when a loop is clearer. py Predict the output new What does this program print? List comprehensions express iterable transformation and filtering in one expression; learn clause order, scope, evaluation, and when a loop is clearer. py Review AI code new Review generated order export List comprehensions express iterable transformation and filtering in one expression; learn clause order, scope, evaluation, and when a loop is clearer. py Spot the bug new Spot the bug in reading normalization List comprehensions express iterable transformation and filtering in one expression; learn clause order, scope, evaluation, and when a loop is clearer. py Quiz new Which statement about lru_cache keys is correct? Cache repeatable calls with functools while handling keys, eviction, invalidation, duplicate concurrent work, and object lifetimes correctly. py Predict the output new How many times does this program print compute? Cache repeatable calls with functools while handling keys, eviction, invalidation, duplicate concurrent work, and object lifetimes correctly. py Review AI code new Review a generated invoice cache Cache repeatable calls with functools while handling keys, eviction, invalidation, duplicate concurrent work, and object lifetimes correctly. py Spot the bug new Spot the bug in the LRU cache Cache repeatable calls with functools while handling keys, eviction, invalidation, duplicate concurrent work, and object lifetimes correctly. py Quiz new What does lru_cache thread safety guarantee for two concurrent calls with the same cold k… Cache repeatable calls with functools while handling keys, eviction, invalidation, duplicate concurrent work, and object lifetimes correctly. py Quiz new On Python 3.14, when should multi-input map use strict=True? Transform, select, and reduce Python iterables while handling lazy evaluation, empty inputs, and mismatched input lengths correctly. py Predict the output new What does this program print? Transform, select, and reduce Python iterables while handling lazy evaluation, empty inputs, and mismatched input lengths correctly. py Predict the output new What value does this left-to-right reduction print? Transform, select, and reduce Python iterables while handling lazy evaluation, empty inputs, and mismatched input lengths correctly. py Review AI code new Review a generated payment summary Transform, select, and reduce Python iterables while handling lazy evaluation, empty inputs, and mismatched input lengths correctly. py Spot the bug new Spot the bug in sensor filtering Transform, select, and reduce Python iterables while handling lazy evaluation, empty inputs, and mismatched input lengths correctly. py Quiz new What does configured_port or 8000 return when configured_port is 0? Understand how Python binds names to objects and builds programs from control flow, functions, exceptions, and modules. py Quiz new Which try suite best handles conversion of one user-supplied quantity? Understand how Python binds names to objects and builds programs from control flow, functions, exceptions, and modules. py Predict the output new What does this program print? Understand how Python binds names to objects and builds programs from control flow, functions, exceptions, and modules. py Review AI code new Review generated order total Understand how Python binds names to objects and builds programs from control flow, functions, exceptions, and modules. py Spot the bug new Spot the bug in the mutable default Understand how Python binds names to objects and builds programs from control flow, functions, exceptions, and modules. py Quiz new Which construct binds a name in the current code block? Scope controls where names are visible, while namespaces hold bindings; learn LEGB, global, nonlocal, and Python's special scope boundaries. py Quiz new In a Python 3.14 function, what happens after locals()["count"] = 3? Scope controls where names are visible, while namespaces hold bindings; learn LEGB, global, nonlocal, and Python's special scope boundaries. py Predict the output new What does this program print? Scope controls where names are visible, while namespaces hold bindings; learn LEGB, global, nonlocal, and Python's special scope boundaries. py Predict the output new What does this program print? Scope controls where names are visible, while namespaces hold bindings; learn LEGB, global, nonlocal, and Python's special scope boundaries. py Review AI code new Review generated tenant pricing handlers Scope controls where names are visible, while namespaces hold bindings; learn LEGB, global, nonlocal, and Python's special scope boundaries. py Spot the bug new Spot the bug in the invoice renderer Scope controls where names are visible, while namespaces hold bindings; learn LEGB, global, nonlocal, and Python's special scope boundaries. py Quiz new Which expression accepts a list on the right without converting it first? Model unique members, membership, and set algebra with hashable values while avoiding unstable order, input mutation, and equality surprises. py Predict the output new What does this program print? Model unique members, membership, and set algebra with hashable values while avoiding unstable order, input mutation, and equality surprises. py Quiz new A cleanup operation may run repeatedly, and an already-absent member is valid. Which oper… Model unique members, membership, and set algebra with hashable values while avoiding unstable order, input mutation, and equality surprises. py Review AI code new Review generated permission plan Model unique members, membership, and set algebra with hashable values while avoiding unstable order, input mutation, and equality surprises. py Spot the bug new Spot the bug in customer ID export Model unique members, membership, and set algebra with hashable values while avoiding unstable order, input mutation, and equality surprises. py Quiz new What happens when two registered, unrelated ABCs both recognize an argument class and nei… singledispatch selects an implementation by the first argument's runtime type; use registration, inheritance, ABCs, and method dispatch safely. py Quiz new How should singledispatchmethod and classmethod be stacked on the generic method? singledispatch selects an implementation by the first argument's runtime type; use registration, inheritance, ABCs, and method dispatch safely. py Predict the output new What does this program print? singledispatch selects an implementation by the first argument's runtime type; use registration, inheritance, ABCs, and method dispatch safely. py Review AI code new Review a generated plugin encoder singledispatch selects an implementation by the first argument's runtime type; use registration, inheritance, ABCs, and method dispatch safely. py Spot the bug new Spot the bug in singledispatch routing singledispatch selects an implementation by the first argument's runtime type; use registration, inheritance, ABCs, and method dispatch safely. py Quiz new What does @convert.register on a value: int | float implementation register in Python 3.1… singledispatch selects an implementation by the first argument's runtime type; use registration, inheritance, ABCs, and method dispatch safely. py Quiz new Which expression wraps the string "Paris" in a one-item tuple without iterating over its … Use tuples for fixed-shape data, with precise rules for packing, unpacking, shallow immutability, hashing, and named records. py Predict the output new What does this program print? Use tuples for fixed-shape data, with precise rules for packing, unpacking, shallow immutability, hashing, and named records. py Review AI code new Review generated reading index Use tuples for fixed-shape data, with precise rules for packing, unpacking, shallow immutability, hashing, and named records. py Spot the bug new Spot the bug in the tuple key Use tuples for fixed-shape data, with precise rules for packing, unpacking, shallow immutability, hashing, and named records. py Quiz new After first, *middle, last = (10, 20, 30, 40), what are middle and its type? Use tuples for fixed-shape data, with precise rules for packing, unpacking, shallow immutability, hashing, and named records. py Quiz new Which statement about dynamic typing and annotations is accurate? Learn how Python names bind to objects, then handle built-in types, truth values, conversion, aliases, mutability, and annotations correctly. py Quiz new What is the safest description of int() at an input boundary? Learn how Python names bind to objects, then handle built-in types, truth values, conversion, aliases, mutability, and annotations correctly. py Predict the output new What does this program print? Learn how Python names bind to objects, then handle built-in types, truth values, conversion, aliases, mutability, and annotations correctly. py Predict the output new What does this program print? Learn how Python names bind to objects, then handle built-in types, truth values, conversion, aliases, mutability, and annotations correctly. py Review AI code new Review generated order total Learn how Python names bind to objects, then handle built-in types, truth values, conversion, aliases, mutability, and annotations correctly. py Spot the bug new Spot the bug in the cents parser Learn how Python names bind to objects, then handle built-in types, truth values, conversion, aliases, mutability, and annotations correctly.
No practice items match these filters.