Python comes with a lot of helpful functions out of the box like print, input and launch_ze_missiles, but there’s a lot of stuff you don’t get out of the box. The import statement allows you to access extra functions and other code.

For instance, if you’re pining to do some trigonometry, you can import the math package:

>>> import math
>>> math.sin(666)
>>> math.pi
>>> math.cos(math.pi)

(This is more pleasant than the alternative of taking a year of calculus and then writing your own sin function.)

There are many more packages at your disposal. Try importing the antigravity package some time.

previous: for loops next: list comprehensions