AnyCompiler

Modules and the Standard Library

Python ships with a large standard library — modules for math, dates, random numbers, file handling, and much more — all available without installing anything, just by writing import.

import math
print(math.sqrt(16))
print(math.pi)
print(math.ceil(4.2))
print(math.floor(4.8))
Output
4.0
3.141592653589793
5
4

Once imported, everything in a module is accessed with module.thing — math.sqrt, math.pi, and so on. The random module works the same way, and can be made reproducible with a seed:

import random
random.seed(42)
print(random.randint(1, 100))
Output
82

Without random.seed(), you'd get a different number every run — seeding it makes the sequence deterministic, which is why the output above is guaranteed to match if you run this exact code yourself.

What works here, and what doesn't

This compiler runs each submission in an isolated sandbox with no internet access and no persistent storage between runs. That means Python's standard library modules (math, random, datetime, json, collections, and so on) all work exactly as shown above — but pip install-based third-party packages (like requests, pandas, or numpy) aren't available, since there's no network access to install them.

For learning the language itself, the standard library covers everything in this tutorial. If you later need a third-party package for a real project, that's when you'd move to a local Python install or a full project environment.

That's the core of the language. From here, the best next step is practice — pick a small idea and build it using what you've learned across these lessons.

Practice exercise

Import the math module and print the square root of 81 using math.sqrt().

← Classes and ObjectsMore lessons coming soon