Some text some message..
Back 2 ✅ Variables in Python – Explained Simply 19 Jun, 2025

In Python, variables are used to store data values. Think of a variable as a labeled box where you can store a value, and later refer to it by the label.


🧠 Key Concepts

Concept Description
Variable Name The label used to refer to a value.
Assignment Operator The equals sign = assigns a value to a variable.
Dynamic Typing Python automatically detects the data type of the variable.

🧪 Example:

name = "Abhishek"
age = 30
is_student = True
height = 5.9

Here:

  • name is a str (string)

  • age is an int (integer)

  • is_student is a bool (boolean)

  • height is a float (decimal)


🔁 You Can Change a Variable's Value

x = 10
x = "Now I'm a string"

Python allows variables to change types because it's dynamically typed.


Invalid Variable Names

  • Cannot start with a number

  • Cannot contain spaces

  • Cannot use special characters like @, #, $

Valid Examples:

my_var = 100
userName = "Abhi"
_total = 99

Invalid Examples:

1st_place = "Gold"     # Starts with a number
user name = "Abhi"     # Contains space
user@name = "Abhi"     # Contains special character

📦 Multiple Assignments

a, b, c = 1, 2, 3

📌 Same Value to Multiple Variables

x = y = z = 100

🔍 Check Variable Type

type(x)