Variables and Keywords in python

Variables and Keywords in python


  • Variables



Variable is a value that can be change by the effect of the conditions or processes in the program.
Variables create a virtual location in RAM (Random Access Memory) for store data while running the program.



There are several rules in creating a variable.

  • Variable name must starts with a letter or underscore. ( _ )
  • Can't use reserved words (Keywords) as the variable name.
  • Can not obtain the spaces.
  • Variable can only have alpha-numeric characters and underscore. (a-z, A-Z, 0-9, _)
  • There is no limit for the variable name.


  • Keywords

Key words (Reserved words) are special in programming. They reserved for do a special task.
Python has 36 key words.

if             For make a condition

elif          For use many condition statements 

else          For the last condition statement

for           For create a loop

while       For create a loop

True         For Boolean true value

False        For Boolean false value

and           For logical operation

or             For logical operation

not           For logical operation

import     For import a module

try            For make try......except statement 

raise         For raise an exception

except      When except occurs use with that

return       Exit from a function with return value

def           For make a function

class        For make a class 

Those are some of most usable keywords.


References :

W3schools 


Read more: 

 Read about python

IF/ELIF/Else statements

 

 ***

0 comments:

Post a Comment