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. |
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)
x = 10
x = "Now I'm a string"
Python allows variables to change types because it's dynamically typed.
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
a, b, c = 1, 2, 3
x = y = z = 100
type(x)