Skip to content

1.2.1 Variable Definition and Assignment ​

In Python, a variable is created when a value is assigned to a name.
No explicit type declaration is required.


Assigning Values to Variables ​

The assignment operator = is used to assign a value to a variable.

A variable:

  • Has a name
  • Stores a value
  • Refers to an object in memory

Python determines the variable’s data type automatically based on the assigned value.


Reassigning Variables ​

Variables can be reassigned to new values at any time.

When a variable is reassigned:

  • The old value is replaced
  • The variable may change its data type
  • The variable name remains the same

This behavior is known as dynamic typing.


Variable Usage Rules ​

  • A variable must be assigned before it is used
  • Variable names are case-sensitive
  • Using clear names improves readability

📌 Note:
Python variables are references to objects, not fixed memory containers.