Account
Categories

Math Module


Definition

It is a module in the Python Standard Library that is ready to use in a Python program for performing basic mathematical operations such as square root, exponentiation, factorial, and rounding.

It helps to solve math problems easily.

Now you will clearly understand the code logic with the help of the flowchart.

Math Module Flowchart :

Start
↓
You write program and import math module
import math
↓
Python loads math module
↓
math module provides mathematical functions
↓
You calculate square root
math.sqrt(16)
↓
Module finds square root of 16
↓
Result comes  → 4.0
↓
You calculate factorial
math.factorial(4)
↓
Module finds 4 × 3 × 2 × 1
↓
Result comes  → 24
↓
Print outputs
4.0
24
↓
End

Syntax:


import math

Example:


import math

print(math.sqrt(16))
print(math.factorial(4))

Output:

Exercise

Use math module to find square root of 25 and factorial of 5 using Python.