Python Modules

Functions and attributes

import math
dir(math)

Shorten module

import math as m
# => True
math.sqrt(16) == m.sqrt(16)

Import all

from math import *

From a module

from math import ceil, floor
print(ceil(3.7))   # => 4.0
print(floor(3.7))  # => 3.0

Import modules

import math
print(math.sqrt(16))  # => 4.0
Comments