Every value in Python has a type that determines what you can do with it. You don't declare types, but knowing them is essential — half of all beginner bugs are a value being a different type than you assumed.
The core built-in types
| Type | Example | Use for |
|---|---|---|
int | 42, -7 | Whole numbers |
float | 3.14, 7.5 | Decimal numbers |
str | "hello" | Text |
bool | True, False | Truth values |
NoneType | None | Absence of a value |
count = 42 # intprice = 7.5 # floatname = "Albero" # stractive = True # boolresult = None # NoneType — a deliberate "no value"
Strings
Strings are text in quotes (single or double). They support indexing, slicing and many methods:
s = "Python"len(s) # 6s[0] # 'P' (indexing)s[-1] # 'n' (from the end)s[0:3] # 'Pyt' (slicing)s.upper() # 'PYTHON'"is fun".split() # ['is', 'fun']f"{s} rocks" # f-string interpolation
Checking types
type(42) # <class 'int'>isinstance(7.5, float) # Trueisinstance(42, (int, float)) # True — any of these types
Key takeaways
- 01Core types: int, float, str, bool, and None (NoneType).
- 02Strings support indexing, slicing and rich methods; f-strings interpolate values.
- 03None represents a deliberate absence of a value.
- 04Check types with isinstance(x, T), the idiomatic choice over type(x) == T.
