Basic mathematical modules

Python provides two essential modules for mathematical operations: math and cmath. The math module is used for performing mathematical operations on real numbers, while the cmath module is designed for complex numbers. Understanding these modules is crucial for efficiently handling various mathematical computations in Python.

The math Module

The math module in Python provides a wide range of mathematical functions and constants. It is mainly used for operations involving real numbers.

Importing the math Module
import math

The cmath Module

The cmath module is used for performing mathematical operations on complex numbers. Complex numbers have both real and imaginary parts, which are represented as a + bj in Python, where j is the imaginary unit.

Importing the cmath Module
import cmath