Python Numbers and Mathematics

1. Numeric Data Types in Python

integer_num = 10
float_num = 3.14
complex_num = 2 + 5j

print(type(integer_num))  # <class 'int'>
print(type(float_num))    # <class 'float'>
print(type(complex_num))  # <class 'complex'>

Python supports three primary numeric types: int, float, and complex.


2. Basic Mathematical Operations

a = 12
b = 5

print(a + b)   # Addition → 17
print(a - b)   # Subtraction → 7
print(a * b)   # Multiplication → 60
print(a / b)   # Division → 2.4

Core arithmetic forms the foundation of all numeric computation.


3. Floor Division and Modulus

Used in quotient-remainder calculations.


4. Power and Exponentiation

The ** operator raises a number to a specified power.


5. Math Module Basics

The math module provides advanced mathematical functions.


6. Trigonometric Functions

Used extensively in scientific and engineering calculations.


7. Rounding Numbers

round() limits decimal precision for display and computation.


8. Absolute and Sign Functions

Used for magnitude and sign manipulation.


9. Random Number Generation

Facilitates simulation, sampling, and stochastic processes.


10. Statistical Operations

The statistics module enables descriptive data analysis.


Last updated