Basic Data Types
Python has several built-in data types. You don't need to declare them; Python infers the type from the value. The most basic types are integers, floats, strings, and booleans.
Numeric Types
- int – integer numbers (e.g., 10, -5, 1000)
- float – floating-point numbers (e.g., 3.14, -0.001)
- complex – complex numbers (e.g., 2+3j) – less common for beginners
age = 25 # int
pi = 3.14159 # float
complex_num = 2 + 3j # complex
Text Type: String (str)
Strings can be enclosed in single quotes, double quotes, or triple quotes for multi-line.
name = "Alice"
message = 'Hello'
multiline = """This is a
multi-line string"""
Boolean (bool)
Can be `True` or `False` (note capital letters).
is_valid = True
is_ready = False
Type Conversion
You can convert between types using functions like `int()`, `float()`, `str()`.
age_str = "25"
age_int = int(age_str) # 25 (int)
price = 19.99
price_str = str(price) # "19.99"
You can check the type of a variable with `type()`.
Two Minute Drill
- Basic data types: int, float, str, bool.
- Python is dynamically typed – you assign without declaring type.
- Use `int()`, `float()`, `str()` to convert types.
- `type()` returns the type of a variable.
- Boolean values are `True` and `False` (capitalized).
Need more clarification?
Drop us an email at career@quipoinfotech.com
