Variables and data types
In Python, a variable is created the moment you first assign a value to it. You do not need to declare its type.
| Type | Description | Example |
|---|---|---|
int | Integer numbers | 42, -10 |
float | Decimal numbers | 3.14, -0.5 |
str | Text strings | "Hello" |
bool | Booleans (True, False) | True |
None | Absence of value | None |
Type conversion
You can convert types with functions like:
int("5") # 5
str(42) # "42"
float("3.14") # 3.14