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. Many other languages use lowercase true/false/null instead, so 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, each with genuinely different rules — picking the right one for the job matters.
Python raises an error rather than silently guessing when types don't match — this is deliberate, not a limitation:
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, Python won't do it for you.
None, False, and 0 are not the same thing
None, False, and 0 are three different values, even though all three are falsy in an if check. None means "no value was ever set," False means "a boolean, specifically false," and 0 means "the number zero." Mixing them up — for example, using 0 as a placeholder for "not set yet" — makes bugs harder to track down later, since 0 is a perfectly valid, meaningful number in a lot of code.