Next →

What is a Variable in Python?

A variable is like a container for storing data. In Python, you can create a variable just by assigning a value to a name:

name = "Alice"

In this example, the variable name holds the string "Alice".

Basic Data Types

Python has several built-in data types. Here are the ones you’ll use most often:

String (str): Text, wrapped in quotes.
Example:

‍city = "London"

Integer (int): Whole numbers.
Example:

age = 30

Float (float): Numbers with decimals.
Example:

height = 5.9

Boolean (bool): True or False values.
Example:

is_hungry = True

You don’t need to declare a type — Python figures it out automatically.

Why Variables Matter in Analytics

Variables let you store and reuse data. In analytics, this might be a column name, a value you’re filtering by, or a calculation result. Mastering variables early sets you up to handle data later.