Junior — Middle
What functions or modules from the math library have you used in your projects?
sobes.tech AI
Answer from AI
The Python math module provides many useful functions for mathematical operations. Some of the frequently used ones include:
math.sqrt(x)— calculates the square root.math.pow(x, y)— raises to a power.math.ceil(x)— rounds up to the nearest integer.math.floor(x)— rounds down to the nearest integer.math.factorial(n)— calculates factorial.math.gcd(a, b)— finds the greatest common divisor.- Trigonometric functions:
math.sin(x),math.cos(x),math.tan(x).
Example usage:
import math
print(math.sqrt(16)) # 4.0
print(math.factorial(5)) # 120
print(math.gcd(48, 18)) # 6
These functions are often used in computational problems, algorithms, and data processing.