← 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'>
Ready to go further?

These free tutorials are a preview, our Backend Development cohort covers it in depth, with a real project and a cohort alongside you. Closes Nov 30

Enroll in Backend Development

Cookie preferences

Choose what you're comfortable with. You can change this any time from the footer.

Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account