Python Math function

 import math


# 1. Square root

print(math.sqrt(25))

# Output: 5.0


# 2. Power

print(math.pow(2, 3))

# Output: 8.0


# 3. Absolute value

print(math.fabs(-10))

# Output: 10.0


# 4. Ceiling

print(math.ceil(4.2))

# Output: 5


# 5. Floor

print(math.floor(4.8))

# Output: 4


# 6. Factorial

print(math.factorial(5))

# Output: 120


# 7. Maximum using built-in max()

print(max(10, 20, 5))

# Output: 20


# 8. Pi

print(math.pi)

# Output: 3.141592653589793


# 9. Sine

print(math.sin(math.radians(90)))

# Output: 1.0


# 10. Logarithm

print(math.log(10))

Comments