← Courses

Python for AI — Beginner Foundations

Data Science

Libraries & APIs · Lesson 52 of 76

Import packages

import brings a module's tools into your program. There are a few styles:

Python
  • import module — then use module.tool.
  • import module as short — a handy shorter name.
  • from module import tool — grab a single tool by name.

Put your imports at the top of the file, so anyone reading it sees the dependencies first.

Your turn: from math import sqrt and print sqrt(81).

You’re reading for free. Sign in to keep your progress and earn a certificate when you finish.Sign in to keep my progress →