Python has several built-in data types. This lesson covers the simple ones in depth; the collection types (list, tuple, dict, set) get their own dedicated lessons shortly, since each has enough to it to deserve one.
| Type | Holds | Example |
|---|---|---|
| str | Text | "Hello" |
| int | Whole numbers | 42 |
| float | Decimal numbers | 3.14 |
| bool | True or False | True |
| NoneType | No value at all | None |
Capitalization matters here
True, False, and None are capitalized in Python — unlike PHP's lowercase true/false/null, or JavaScript's. This trips up almost everyone coming from another language at least once.
x = 42
print(type(x)) # <class 'int'>
print(isinstance(x, int)) # True| Type | Ordered? | Changeable? | Duplicates allowed? |
|---|---|---|---|
| list | Yes | Yes | Yes |
| tuple | Yes | No | Yes |
| dict | Yes (insertion order) | Yes | Keys must be unique |
| set | No | Yes | No |
Each of these gets its own lesson soon. For now, the key thing to notice is that Python has four distinct built-in collection types with genuinely different rules — PHP, by contrast, uses one flexible array type for most of these jobs.
This is a real, important difference from PHP's type juggling: Python raises an error rather than silently guessing when types don't match:
result = "5" + 3
# TypeError: can only concatenate str (not "int") to strThe next lesson, Type Conversion, covers converting between types deliberately — which is required here, not optional the way it often is in PHP.