Python Variables

Python Variables are the memory locations in which we can store value.


x=10


Here, x is variable and 10 is value.

Variable names are used to have some descriptive names, So that developers can understand more clearly.
There are some rules for variable names:

  • The variable name consist of alphabets, numbers and underscore only.
  • The first character in variable name can't be a number.
  • a-b-c, variable!, 1variable, #variable, all are invalid variables.
  • a_b_c, variable, variable1, _variable_ , all are valid variables.



Let's have some program on variables in python IDE,


>>>x=10


After writing this press enter key


>>>x
10


After writing x, press enter it will execute the value stored in that variable.

Some more programs in IDE,


>>>x=11
>>>y=25
>>>x
10
>>>y
25



Let's do with words,


>>>name='10xMorningStar'
>>>name
10xMorningStar

Back To Top