Tsallaka zuwa abun ciki
Justice Tech School

The math Module

The math module adds sqrt, ceil, floor, pow, log, sin, cos, factorial, gcd, and constants such as pi and e. math.isclose compares floats safely.

Example
import math
print(math.sqrt(144))
print(math.ceil(4.1), math.floor(4.9))
print(math.factorial(5))
print(math.gcd(12, 18))
print(round(math.pi, 4))
print(math.isclose(0.1 + 0.2, 0.3))

Result

12.0
5 4
120
6
3.1416
True

Exercise

Round up to the next whole number.

math.(4.1)

Quiz Test

Why use math.isclose for floats?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.