Import.math topic - where is it?

In which topic/lesson is the import.math covered? I think I either have a gap in my notes or I just haven’t covered it for some reason.

1 Like

It might come up before the Modules unit, but for sure it is also covered in that unit.

It won’t be written like that, at any length.

import math

All imports should occur at the start of the script (top lines).

We access that namespace by module name dot method name:


PI = math.pi

Note that math.pi is a constant, not a method, so we do not invoke it.

Python 2.x Mathematical functions

Python 3.x Mathematical functions