Skip to main content

Variables and data types

In Python, a variable is created the moment you first assign a value to it. You do not need to declare its type.

TypeDescriptionExample
intInteger numbers42, -10
floatDecimal numbers3.14, -0.5
strText strings"Hello"
boolBooleans (True, False)True
NoneAbsence of valueNone

Type conversion

You can convert types with functions like:

int("5")       # 5
str(42) # "42"
float("3.14") # 3.14