SimpleTuts.com

Python Math Functions

Built-in functions like `abs()` and `round()` can be used directly in Python for simple calculations. With the `math` module imported, additional advanced functions such as trigonometric calculations (`sin()`, `cos()`), logarithmic operations (`log()`, `log10()`), and mathematical constants (`pi`, `e`) are readily available for more complex mathematical tasks.


x = min(5, 10, 25)
y = max(5, 10, 25)

print("Minimum : ",x)
print("Maximum : ",y)

x = abs(-7.25)

print("Absolute : ",x)

x = pow(4, 3)

print("Power : ",x)
                
Python Online Compiler

Using math module


import math

x = math.sqrt(64)

print("Square root : ",x)

x = math.ceil(1.4)
y = math.floor(1.4)

print("Ceil : ",x) # returns 2
print("Floor : ",y) # returns 1

x = math.pi

print("Pi : ",x)
                
Python Online Compiler