Importing modules

The many modules can easily be imported.

>>> import math
>>> math.sqrt(2.0)
1.4142135623730951

Import all objects from a module into current scope:

>>> from math import *
>>> sqrt(2.0)*cos(pi/4)
1.0000000000000002

Only import certain objects from a module:

>>> from math import exp, pi
>>> exp(pi)
23.140692632779267
>>> cos(pi)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'cos' is not defined

Aliasing:

>>> from math import pi, sqrt as rt
>>> 1/rt(2*pi)
0.3989422804014327