PYTHON BASICSChapter 1 · Python Basics
Converting types
Every value has a type: int, float, str or bool. Ask for it with type(value). Text that looks like a number is still text until you convert it with int() or float(), and str() turns anything into text. It matters because "2" + "3" is "23", not 5.
Worked example
How it reads
+joins strings but adds numbers, so the type decides what happensint("2")makes the number 2 from the text "2"type(x)tells you what you are holding
Common mistakes
int("seven")raises ValueError. Only text made of digits converts.bool("False")isTrue: any non-empty string counts as true.

Cloud tip:
int("3.7") fails. When text might have a decimal point, convert to float first: int(float("3.7")) is 3.

