1. The math Module
Trigonometry, Logarithms, Constants
- Provides C-standard mathematical functions: `math.sqrt`, `math.pow`, `math.sin`, `math.cos`, `math.log`, `math.gcd`.
- Rounding utilities: `math.floor` (rounds down to -∞), `math.ceil` (rounds up to +∞), `math.trunc` (truncates decimals toward zero).
- Mathematical constants: `math.pi`, `math.e`, `math.inf`, `math.nan`.
import math
print("math.ceil(4.1):", math.ceil(4.1)) # 5
print("math.floor(4.9):", math.floor(4.9)) # 4
print("math.gcd(24, 36):", math.gcd(24, 36)) # 12
💡 Key Takeaway: Use math functions for high-speed floating point computations.