A module is just a .py file — Python lets you pull any file of tools into any other file with a single word: import.
1 One Job per File
A module is a plain .py file; group related functions and constants in it and import them anywhere.
2 Batteries Included
math, random, datetime, re — the standard library ships hundreds of ready-made modules.
3 Dot Access
import math gives you a namespace: math.sqrt, math.pi — no clashes with your own names.
4 Import Once
A module runs only the first time it is imported; after that Python reuses the cached copy.
One file, many tools
One Job per File1A module is a plain .py file; group related functions and constants in it and import them anywhere. Batteries Included2math, random, datetime, re — the standard library ships hundreds of ready-made modules.
Dot Access3import math gives you a namespace: math.sqrt, math.pi — no clashes with your own names.
Import Once4A module runs only the first time it is imported; after that Python reuses the cached copy. 4 building blocks make up One file, many tools
Press Run and follow import mytools — a lot happens before the first tool is usable.
Tab one is a module you wrote; tab two imports it. Watch mytools.py run exactly once, on import.
mytoolsA comment names the file — modules are ordinary .py files you can open and read.
Memory
no variables yet — press play
Console
output appears as the program runs…
Click a term, then click its description to lock the pair.
5 conceptsTap a card to expand ?import mathdrops into place
?from math import sqrtdrops into place
?import randomdrops into place
?mytools.pydrops into place
?__pycache__drops into place
One import for chance, one for math — and a seed that fixes the dice.
Your predicted output — one line per console line
Hint: random.seed(1) locks the dice: the same seed always produces the same rolls. Then sqrt of that number is printed at full precision.
Python checks its cache before touching the disk — and never re-runs a module it already loaded.
process decision input / output start / end
01A module is any .py file; import it by its file name, without the .py.
02import math keeps tools namespaced under math. — from math import sqrt brings one tool in directly.
03Module code runs exactly once, on the first import; later imports reuse the sys.modules cache.
04random.seed(n) makes chance deterministic: same seed, same rolls.
05Your own files are importable too — bundles of modules in folders are called packages.