← Python tutorial

Python

Variables & Data Types

Python variables don't need a declared type — just assign a value with = and Python figures out the type from what you assigned.

Example: checking a variable's type

name = "Ada"
age = 21
gpa = 3.8

print(type(name), type(age), type(gpa))
<class 'str'> <class 'int'> <class 'float'>

The core built-in types: str (text), int (whole numbers), float (decimals), and bool (True/False). Note Python distinguishes int from float — unlike JavaScript, which uses one number type for both — which matters the moment you divide two whole numbers and get a decimal result back.

Example
name = "Ada"
age = 21
gpa = 3.8

print(type(name), type(age), type(gpa))
Output
<class 'str'> <class 'int'> <class 'float'>