PYTHON TUTORIAL FOR BEGINNERS
Source: www.youtube.com/@RishabhMishraOfficial
Chapter - 04
Variables in Python
• What is a Variable
• Variables - examples
• Variable Naming Rules
Variables in Python
A variable in Python is a symbolic name that is a reference or pointer to an
object.
In simple terms, variables are like containers that you can fill in with different
types of data values. Once a variable is assigned a value, you can use that
variable in place of the value.
We assign value to a variable using the assignment operator (=).
Syntax: variable_name = value
Example: greeting = "Hello World"
print(greeting)
Variable Examples
Python can be used as a powerful calculator for performing a wide range of
arithmetic operations.
PythonLevel = "Beginner" # pascal case
pythonLevel = "Beginner" # camel case
pythonlevel = "Beginner" # flat case
python_level = "Beginner" # Snake case
P y t h o n N o t e s b y R i s h a b h M i s h ra
x = 10
print(x+1) # add number to a variable
a, b, c = 1, 2, 3
print(a, b, c) # assign multiple variables
Variable Naming Rules
1. Must start with a letter or an underscore ( _ ).
2. Can contain letters, numbers, and underscores.
3. Case-sensitive (my_name and my_Name are different).
4. Cannot be a reserved keyword (like for, if, while, etc.).
_my_name = "Madhav"
for = 26
# ‘for’ is a reserved word in Python
Python Tutorial Playlist: Click Here
https://www.youtube.com/playlist?list=PLdOKnrf8EcP384Ilxra4UlK9BDJGwawg9
P y t h o n N o t e s b y R i s h a b h M i s h ra