Python Variable

Python Variable

What is variable?

Python variable is the name given to a memory location to store a value. you can say that, a variable is like a box and value is the thing, which is placed in the box. For example " a = 7 ". here, 'a' is the variable name and '7' is the value stored by 'a'.

Rules for defining a variable.

List of important rules for defining a variable are :

  • A Variable name is case sensitive. It means, if you write a variable name that has a lowercase first letter and the same name with a uppercase first letter, then python will read it as two different variable name. For example " a " , " A " are two different variable name.

  • A variable name contains alphabet, numbers and underscore. For example " a2b " , " ab_33 " , etc.

  • A variable name cannot start with a number. For example " 3b2 " , " 23ram " , etc.

  • A variable name can only start with an alphabet and underscore. For example " Ram " , " _2abs " , etc.

  • A variable name can not be a python's keyword. For example " import " , " is " , etc.

  • No spacing is allowed inside a variable name. For example " goo gle " , " you tube " , etc.

Assign your name as a variable in comment section.

Comments