Articles → Python → Variables In Python

Variables In Python






What Are The Variables?





How To Declare A Variable?




  1. Specifying the variable name
  2. Followed by assignment operator i.e., ‘=’
  3. Followed by value


name = "gyan"
age = 30



Multiple Assignments Of Variables In Python




x= y = z = 2

print(x,y,z)




Picture showing the output of Multiple assignment of variables in python




x= y = z = 2
x = x + 1
print(x,y,z)




Picture showing the output of Multiple assignment of variables in python





Declaring Multiple Variables In One Line




width, height = 20,40

print("width:",width)
print("height:",height)




Picture showing the output of Declaring multiple variables in one line



Rules Of Creating Variables




  1. Variable names are case-sensitive
  2. Variable names should only contain alphabet, numbers, and underscore
  3. Keywords should not be used as the variable name
  4. Variable names should start with the alphabet or underscore



Posted By  -  Karan Gupta
 
Posted On  -  Thursday, January 31, 2019
 
Updated On  -  Tuesday, March 26, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250