Examples
Open an example to explore its Python code and transformed one-liner.
- FizzBuzz · for, if / elif / elseCount from 1 to 20 with conditions, modulo, and formatted strings.Open in playground →
- Binary search · while, break, elseFind a number in a sorted list by halving the search range.Open in playground →
- Prime sieve · nested loops, lists, slicesCross out multiples to find prime numbers up to 40.Open in playground →
- Scoreboard · comprehensions and collectionsBuild a scoreboard with list, set, dict, and generator comprehensions.Open in playground →
- Inventory · annotations, unpacking, slicesUpdate a small inventory with annotations, unpacking, and deletion.Open in playground →
- Running totals · functions and decoratorsDefaults, a decorator, keyword-only arguments, and a lambda.Open in playground →
- Async score lookup · top-level awaitAwait an async function directly in the playground.Open in playground →
- Bank account · classes and inheritanceObjects, methods, attributes, inheritance, and a property.Open in playground →
- Report reader · imports and withParse numbers from an in-memory file with a context manager.Open in playground →
- Command parser · sequence and mapping patternsRoute commands using OR, sequence, mapping, star, and singleton patterns.Open in playground →
- Bit flags · operators and expressionsCombine arithmetic, bitwise, comparisons, and conditional expressions.Open in playground →
- Input validation · try, finally, raise fromValidate each score, handling errors and always recording the attempt.Open in playground →
- Call counter · global assignmentsTrack calls to a function with a module-level variable.Open in playground →
- Prime finder · continue, break, for elseSkip even candidates, then look for an odd divisor.Open in playground →
- Assignment trace · target and value orderPython evaluates a regular assignment's value before its target.Open in playground →
- Points · class patterns and guardsClass patterns can unpack fields positionally or by name.Open in playground →
- Collatz sequence · while continue and elseRepeatedly halve even values and expand odd values until reaching one.Open in playground →
- Default templateExplore the original multi-feature playground template.Open in playground →