Python's Two Priceless Gem(Keywords And Identifiers)
Gem No 1:- Keywords
Python have reserved words so we cant use variable name, function name or any identifier. They are to delineate the syntax and edifice of the Python language. Python always a case sensitive. There are 33 keywords in python 3.7.
True, False and None are the keywords which comes in lowercase and they must be express as they are. Just check the image given below of all 33 keywords.
Just put an eye on every keywords and try to understand it well.now just move towards secong gem.
Gem No 2:- Identifiers
Identifiers are names given to entities such as classes, functions, variables, etc. It is used to distinguish one entity from another.
Rules for writing identifiers
- Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore
_
. Names likemyClass
,var_1
andprint_this_to_screen
, all are valid example. - An identifier cannot start with a digit.
1variable
is invalid, butvariable1
is a valid name. - Keywords cannot be used as identifiers.
Outputglobal = 1
File "<interactive input>", line 1 global = 1 ^ SyntaxError: invalid syntax
- We cannot use special symbols like !, @, #, $, % etc. in our identifier.
a@ = 0
OutputFile "<interactive input>", line 1 a@ = 0 ^ SyntaxError: invalid syntax
- An identifier can be of any length.
Just put an eye on every identifers in python and try to understand it well.
Comments
Post a Comment