Assignments in Python


☞You can assign a value in different ways :-

1. Single Assignment
2. Multiple Assignment

Single Assignment

Example :

x=10        #single assignment
y=5         #single assignment
z=12        #single assignment
print(x,y,z)

OR

x=10;y=5;z=12   #single assignment in one line
print(x,y,z)
Output
10  5  12
Note :- 
1.You cannot write x=10,y=5,z=12 (SyntaxError)
2.If you want to write in single line, use semi-colon to separate.

Multiple Assignment With Same Value

Example :

x=10        #single assignment
y=10        #single assignment
z=10        #single assignment
print(x,y,z)

OR

x=y=z=10   #Multiple assignment with same value
print(x,y,z)

Output

10  10  10

Multiple Assigment With Different Values

Example :

x=10        #single assignment
y=5         #single assignment
z=12        #single assignment
print(x,y,z)

OR

x,y,z=10,5,12  #Multiple assignment with different values
print(x,y,z)
Output
10 5 12