Python provides strong support for working with numbers, which are one of the most important data types in programming. Numbers are used in calculations, logic building, data science, AI, and many real-world applications.
🧠 What are Numbers in Python?
In Python, numbers are used to represent numeric values for mathematical operations.
👉 In simple words:
- Numbers = values used for calculations
⚙️ Types of Numbers in Python
Python supports three main types of numbers:
🔢 1. Integer (int)
Integers are whole numbers (positive or negative) without decimals.
Example:
a = 10
b = -5
print(a)
print(b)
🔵 2. Float (float)
Floats are numbers with decimal points.
Example:
pi = 3.14
price = 99.99
print(pi)
print(price)
⚡ 3. Complex Numbers (complex)
Complex numbers have a real and imaginary part.
Format: a + bj
Example:
z = 2 + 3j
print(z)
print(type(z))
🧪 Checking Number Types
You can check the type of a number using type().
x = 10
y = 3.5
print(type(x))
print(type(y))
➗ Basic Number Operations
Python allows all mathematical operations on numbers.
Example:
a = 10
b = 3
print(a + b)
print(a - b)
print(a * b)
print(a / b)
🔢 Number Conversion (Type Casting)
You can convert between number types.
Integer to Float
x = 10
print(float(x))
Float to Integer
y = 9.8
print(int(y))
📊 Built-in Number Functions
Python provides useful functions for numbers:
| Function | Description |
|---|---|
| abs() | Absolute value |
| round() | Rounds number |
| pow() | Power function |
| max() | Largest value |
| min() | Smallest value |
Example:
print(abs(-10))
print(round(3.6))
print(pow(2, 3))
🚀 Where Numbers are Used?
Numbers are used in:
- Calculators 🧮
- Banking systems 💰
- Data analysis 📊
- Games 🎮
- AI and machine learning 🤖
🧾 Conclusion
Python numbers are the foundation of all mathematical operations and are essential for building real-world applications.
💡 Final Thought
If you understand numbers well, you can easily handle calculations and logic in any Python program.


0 Comments