What is a variable in Python?
Variables used to store data values. In other words, variables are reserved memory locations for storing values. This means that some space is reserved in your memory when you create a variable.
According to the data type of the variable, the interpreter allocates memory and decides what can be stored in the reserved memory. So by assigning different data types to variables, you can store integers, letters, or decimals in these variables.
Creating Variables:-
A variable is created when you assign a value to it and when you assign a value to a variable, it automatically reserves memory space. the equal mark i.e(=) is used to assign values to variables.
The operand to the left of the equal sign (=) operator is the name of the variable and the operand to the right of the equal sign (=) operator is the value stored in the variable.
For example −
A=10;
here, A is a Variable, and 10 is a value stored in the variable.
Another example is shown in the image below:-

Variable Names
A variable can have a short name (like A and B) or a more descriptive name (Name, Roll_no, Age).
Rules for Python variables:
- The name of a variable must begin with a letter or an underscore character.
- A variable name cannot start with a number
- Variable names contain alpha-numeric characters and underscores (A-z, 0-9 and _)
- Variable names are the case-sensitive(name, Name, and NAME are three different variables)
Legal variable names
myvar = "Technogyyan"
my_var = "Technogyyan"
_my_var = "Technogyyan"
myVar = "Technogyyan"
MYVAR = "Technogyyan"
myvar2 = "Technogyyan"
Illegal variable names
2myvar = "Technogyyan"
my-var = "Technogyyan"
my var = "Technogyyan"
These are some other example of variable:-
X=10
Y=10.5
Z="John"
a = 'John'
my_variable_name = "John"
b = str(3)
c= int(3)
d = float(3)
x, y, z = "Orange", "Banana", "Cherry"
x = y = z = "Orange"
In this image, you will find everything related to variables.
You can check out the first 2 tutorials by clicking on the link below.
Click here
Thank You!!
Define variable in python ?,python variables,python variables in string,python variables in strings,python variables examples,what is python variable,what is variable.



This tutorial gives a clear introduction to Python variables by explaining how values are assigned and stored, along with the basic rules for creating valid variable names. The examples covering integers, floating-point values, strings, multiple assignments, and type conversion make the topic accessible to beginners building their Python fundamentals.
ReplyDeleteThe explanation of variable creation and assignment using the equal sign is especially useful for understanding how Python programs store and work with different types of values. These fundamentals provide a strong starting point for learners following a Python Online Course and progressing from basic syntax toward practical programming.
The section on legal and illegal variable names also highlights important details such as case sensitivity, underscores, and the restriction against starting a variable name with a number. Applying these fundamentals becomes increasingly important when students begin developing Python Projects For Final Year and need to maintain readable and consistent code.
ReplyDeleteThe examples of assigning multiple values, assigning one value to several variables, and converting values with str(), int(), and float() give beginners useful patterns to practice. These concepts can later be connected with broader application development through Python Full Stack Course, where Python fundamentals become part of larger backend and full-stack applications. Python Online Training
ReplyDeletePost a Comment