Skip to content
AgileLogics
4 min read

Modules

Prerequisites: Functions

A module is just a Python file whose functions and variables you can reuse in another file via import. Python also ships many modules built in — the standard library — ready to use with no installation.

import math

print(math.sqrt(16))
print(math.pi)

Expected output

4.0
3.141592653589793

You can also import just one specific name: from math import sqrt lets you write sqrt(16) directly.