Lazo Lab Sign up

Python Fundamentals / Functions and errors

Lesson 33 of 38

Modules and imports

A module is a file of Python code you can reuse. import brings in Python's built-in modules like math, random and datetime, or your own files.

Key points

  • import math
  • from random import choice
  • Your own .py files are modules too
import math
from random import randint
print(math.sqrt(16), randint(1, 6))
Watch a video on thisOpens YouTube search results for “Modules and imports” in a new tab

Quiz · +10 XP

Which line imports the math module?

Log in to save progress and earn XP.