Built-in functions and the math module.
Built-in maths functions: min(), max(), abs(), pow(), round(), sum().
The math module adds many more:
math.sqrt(), math.ceil(), math.floor()
math.pi, math.e
math.factorial(), math.gcd()
Trigonometry: math.sin(), math.cos(), math.radians()
💡 Key Takeaways: Python Math
Mastering Python Math helps you write clean and reliable Python code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
Python Math Code Example
Python
import math
print(min(5, 10, 25), max(5, 10, 25), abs(-7.25), pow(2, 5))
print(math.sqrt(81), math.ceil(1.2), math.floor(1.8))
print("Circle area r=3:", round(math.pi * 3 ** 2, 2))
print("10! =", math.factorial(10))
print("gcd(48, 18) =", math.gcd(48, 18))
Free sign-in required · Google login available
Stuck on something?
Ask the community in the CodesInTech forum.
Need a developer?
Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.
Explore Our Services