math, random, statistics, datetime and zoneinfo
All values are fixed or seeded, so the output is the same every run. Change the seed or the dates and rerun to see how the pieces fit together. isoformat() writes a datetime in the standard form 2026-10-09T09:30:00+05:30 (date, T, time, then the offset from UTC).
Python ships with hundreds of ready-made modules: maths, randomness, dates and time zones, the operating system, iteration tools, statistics and JSON. Knowing what exists, and how to read the documentation, saves you from rewriting what is already built, tested and fast.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 5 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Use statistics to print the mean and median of [4, 8, 15, 16, 23, 42].
Call random.seed(1), then print a list of three dice rolls made with random.randint(1, 6). Then explain in one sentence why running the program again gives the same three numbers.
Print how many days there are from date(2026, 10, 9) to date(2026, 12, 25) (subtract the earlier date from the later one and use .days).
Put the dictionary {"name": "Asha", "scores": [90, 85]} in a variable, then use json.dumps to print it with an indent of 2 and sorted keys.
Explain it without notes
What is the standard library, and how do you know a module belongs to it?
Why do tests and experiments call random.seed(...), and why not use random for passwords?
How should an application treat time zones?
How do you find out how to use a module you have never seen?
Expected output
sqrt: 1.4142135623730951 | ceil: 3 | gcd: 6
hypot: 5.0 | factorial: 120
rolls: [3, 2, 4, 6, 1]
pick: red
shuffled: [2, 6, 4, 3, 1, 5, 7]
mean: 79.6 | median: 85 | mode: 85
stdev: 10.11
launch: 2026-10-09 Friday, 09 October 2026
30 days later: 2026-11-08
days between: 84
in Kolkata: 2026-10-09T09:30:00+05:30
in London: 2026-10-09T05:00:00+01:00