In this video, I have given detailed explanation about variables. what is a variable, how to create variable, how to assign value to a variable, multiple assignments. All this doubts will be cleared in this video.

VARIABLES AND MULTIPLE ASSIGNMENTS

Variables: Variables are reserved memory locations to store value. When a variable is created, some space is reserved into the memory. The assignment is done using the equal sign (=), example A=2(This expression means an integer 2 is saved in the variable A)

Python interpreter allocates memory depending on the datatype which is used. There are many datatypes like integers, float, strings, etc. Every datatype has different bytes of location reserved into the memory.

Let’s see some of the examples:

Name = “Arnold”

Here a string called Arnold is stored in variable called Name.

Age= 25

Here an integer or a number doesn’t require single or double quote to define.

Note: You cannot define variable name with space between two or more words

Example: My name = “Jack”

This will give an error

Correction: MyName = “Jack”

Multiple Assignments: Python allows user to assign single value to multiple variables simultaneously. For example:

a = b = c = d = 50

Here, an integer with value 50 is stored in all the four variables and all of them are assigned to the same memory location. You can also assign different datatypes to multiple variables. For example:

Name, age, income = “Tesla”, 30, 50000

Here, Name is a string which stores “Tesla” and two integer age and income are assigned to store the respective vales 30 and 50000.