54. Math Operations
1. Introduction
Python has built-in operators and the math module for advanced operations.
2. Built-in Arithmetic
print(5 + 3) # 8
print(5 ** 2) # 25
3. math Module Functions
import math
print(math.sqrt(16)) # 4.0
print(math.factorial(5)) # 120
4. Trigonometry
print(math.sin(math.pi / 2)) # 1.0
5. Constants
print(math.pi)
print(math.e)
6. Rounding and Floor/Ceil
print(math.floor(3.7)) # 3
print(math.ceil(3.7)) # 4
7. Random Numbers
import random
print(random.randint(1, 10))
8. Next Steps
✅ You now know math operations in Python.
Next: Working with JSON files.