Numbers, Booleans & None
The core types: int, float, bool, None โ and conversions between them.
Python values have types. The five you will use constantly:
| Type | Meaning | Example |
| --- | --- | --- |
| int | whole numbers | 42, -7 |
| float | decimal numbers | 3.14, -0.5 |
| str | text | "hello", 'a' |
| bool | truth values | True, False |
| NoneType | "no value" | None |
Type inspection
type(x) returns a value's type โ indispensable while learning:
type(42) # <class 'int'>
type(42.0) # <class 'float'>
type("42") # <class 'str'>
Note 42 vs 42.0 vs "42" โ three different types. Python cares.
Conversion
Convert explicitly with int(), float(), str():
int("42") # 42
float("3.5") # 3.5
str(99) # "99"
int("3.5") # ValueError! int() refuses decimal text
Conversions between numbers and text are how programs talk to humans: input arrives as text; math needs numbers; output goes back to text.
Why None exists
None means "nothing here yet" โ the placeholder for a result you do not have.
You will meet it constantly once functions arrive.