Python Mastery – From Basics to Brilliance / Python Fundamentals

Variables & Data Types

A variable is like a container or label that stores information in a computer’s memory. When you assign a value to a variable, you’re giving a name to some data.


💡 Real-life Analogy:

Think of a variable like a jar with a label. You can write anything inside the jar (data), and the label (variable name) tells you what it is.

name = "Alice"
age = 25
is_student = True

In the above example:

  • name stores a string

  • age stores an integer

  • is_student stores a Boolean value


📌 Key Python Data Types:

Data Type

Description

Example

int

Whole numbers

age = 30

float

Decimal numbers

price = 49.99

str

Text

name = "Anna"

bool

True or False

is_logged_in = False

list

Ordered collection

fruits = ["apple", "banana"]

tuple

Immutable list

coordinates = (10, 20)

dict

Key-value pairs

user = {"name": "Tom", "age": 25}

set

Unordered unique items

unique_ids = {1, 2, 3}

✅ Tip: Python is dynamically typed, so you don't need to mention the type explicitly.