Skip to the workspace
Pebellslearn by building

Python syntax & reference

Find the form you need, compare how it behaves, and open the complete explanation when you need more depth.

Python 3.10+ syntax; individual entries identify newer features. Browser exercises use the configured Python runner.

1 matching syntax entry

Test assertions and boundaries

Learn in depth →

A test compares observed behavior against a stated contract on chosen examples.

def test_behavior():
    assert actual == expected

Example

def divide(total, count):
    return total / count
assert divide(10, 2) == 5
print("contract example passed")

Result

contract example passed

Watch for: Use pytest locally for its discovery, parametrization and fixtures. Passing samples does not prove correctness for every input.

Practise this topic →
Complete explanation index (91 lessons indexed)

Your First pytest Suite

Technical sources and review date

Original Pebells examples. Reviewed 2026-10-28.

Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.