Junior Codes
Inventor Studio

Python Modules and import for Kids

Borrow ready-made tools, like math and random, with import.

Start Wonderwild free with Pip

Try 5 starter activities free. Full access is ₹499 a year.

This mission is part of full access. The first missions are free to try.

Modules & import, explained simply

Python comes with a huge toolbox of extra code grouped into modules. Instead of writing everything yourself, you import a module and use its tools.

After import math you can use math.sqrt() for square roots, math.ceil() to round up and math.floor() to round down. The dot means "the tool called this, inside that module".

The random module is a favourite for games: random.randint(1, 6) rolls a dice, and random.choice() picks from a list.

Example: How many buses?

import math

children = 45
seats_per_bus = 20
buses = math.ceil(children / seats_per_bus)
print(f"We need {buses} buses.")

Output

We need 3 buses.

45 ÷ 20 is 2.25, but you cannot book a quarter of a bus, so math.ceil rounds up.

Try this

  • Use random.randint to roll a dice five times.
  • Try math.floor on the same sum and explain why it would be the wrong choice here.
  • Pick a random joke from a list with random.choice.

Practise it in Wonderwild

“Cloud-bus departures”

Mission 29 in Inventor Studio, one of 36 Python missions in Wonderwild.

Your child writes and runs real Python in the browser while Pip reacts to every line. Nothing to install. For ages 7+.

Start Wonderwild free with Pip

Try 5 starter activities free. Full access is ₹499 a year.

This mission is part of full access. The first missions are free to try.

Questions parents and kids ask

Do I need to install math or random?+

No. They are part of Python’s standard library and come with every Python installation.

Where do import lines go?+

At the top of your program, so anyone reading it can see which tools it uses.

Prefer learning with a teacher?

Our live Python for Young Developers course teaches these ideas in small online classes led by a software engineer, with projects and feedback. Every live course also includes 12 months of full Wonderwild access for practice.

See the Python for Young Developers course