5.3 Math Module
- The
math
module contains the kinds of mathematical functions you would typically find on your calculator and some mathematical constants like pi and e
- As we noted above, when we
import math
, we create a reference to a module object that contains these elements.
- If you want more information, you can check out the Math Module Python Documentation.
- Mathematical functions do not need to be constructed. They simply perform a task. They are all housed together in a module called math.
import math
print(math.pi)
print(math.e)
print(math.sqrt(2.0))
print(math.sin(math.radians(90))) # sin of 90 degrees
- Contains number of math stuff: trig, log, etc
- Function: list of statements that can be executed simply by referring to the function's name.
- The process of invoking a function is referred to as a function call.
- The item passed to a function is referred to as an argument.