In [1]:
# Method 1
import math
# In this case library name shall be attached before function/variable name in the library
print(math.pi)
In [2]:
# Method 2
import math as mt
# it's possible to use nick-name for name space of library
print(mt.pi)
In [3]:
# Method 3
from math import pi, cos, sin
# only import specific function/variable
print(pi)
print(cos(pi/6), sin(pi/6)) # 30 deg
In [4]:
# Method 4
from math import *
# import every variable/function and merge name space
# !!! Not recommended !!!
print(pi)
print(cos(pi/4), sin(pi/4))
In [ ]: