Kids Coding

Modules

import a library. math, random, and datetime do work you should not rewrite.

KidsAdvancedModules

Do not rebuild the toolbox

A module is a file of tools you import. math, random, and datetime ship with Python.

math and datetime

import math
import datetime

print(math.sqrt(16))
print(math.pi)
print(datetime.date.today())

Put related functions in their own file, then import it. Your main program stays short and easy to read.

Import one name

from math import

from math import sqrt

print(sqrt(25))

Real life

Using a real calculator and a wall clock instead of inventing them.

math and datetime are tools already in the house. Import them. Do not rebuild them.

Clock and square root

import math
import datetime

print("Sqrt of 81:", math.sqrt(81))
print("Today:", datetime.date.today())

Change one word. Run it. That is how this idea shows up outside the lesson.

Try it

Exercise 1: Import random and print a number from 1 to 3.

Show solution
import random
print(random.randint(1, 3))

FAQ: Modules

Common questions about this page.

What is StudyGrid Kids?

StudyGrid Kids is a free coding path for children: Basic, Intermediate, and Advanced. Lessons use Python in the browser. No account and no install.

Should I run modules examples locally for better learning?

Yes. Use the browser editor on StudyGrid for a quick check, then Download the example and run it on your computer. Local runs show real errors and the real toolchain, which is one of the fastest ways to learn modules in this Kids Coding Python lesson (Modules).

Which kids level should we start with?

Start at Basic if the child has never written code. Choose Intermediate if they can print, use variables, and write a simple if. Choose Advanced if they already use loops and lists.

Do kids need an account or an app?

No. Kids pages are public. Code runs in the Try Python editor at /try. We do not ask children for a name or an email.

What language do kids learn?

Python, with a first HTML page in Intermediate and Advanced. After Advanced, the main Python tutorial is the next step.

Is the kids coding track free?

Yes. The Kids home, the three levels, and the Python editor on StudyGrid (studygrid.in) are free.