Multiple Ways for Assignments in Python


#Multiple Ways for Assignment

# 1. Assigning Same value to multiple variables.
x = y = z = 500
print("X = ",x,": Y = ",y,": Z = ",z)

# 2. Assigning Multiple Values in Multiple Variables.
x,y,z = 100, 200, 300
print("X = ",x,": Y = ",y,": Z = ",z)

#3. Swapping of values of variables
print("Swapping of values of variables")
x, y = y, x
print("X = ",x,": Y = ",y)




Output>>>
X =  500 : Y =  500 : Z =  500X =  100 : Y =  200 : Z =  300Swapping of values of variablesX =  200 : Y =  100




No comments

Post your comments

Powered by Blogger.