currently has 33 keywords. Enter the following statement in
Python’s interactive console. The list of keywords gets displayed!
Example 1.4
>>> import keyword
>>> print (keyword.kwlist)
['False', 'None', 'True', 'and', 'as', 'assert', 'break',
'class', 'continue', 'def', 'del', 'elif', 'else', 'except',
'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is',
'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return',
'try', 'while', 'with', 'yield']
Apart from keywords, you can choose any name (preferably cryptic
but indicative of its purpose) to identify other elements in your
program. However, only alphabets (upper or lowercase), digits and
underscore symbol (‘_’) may be used. As a convention, name of class
starts with an uppercase alphabet, whereas name of function/method
starts with lowercase alphabet. Name of variable normally starts with
alphabet, but in special cases an underscore symbol (sometimes
double underscore __) is seen to be first character of variable’s
name.
Some examples of valid and invalid identifiers:
Valid identifiers Invalid identifiers
name, FileName, yr1sem1, EMP,
roll_no, sum_of_dig, _price,
__salary, __function__
123, sub-1, yr1.sem1,
roll no, 'price',
*marks*
1.5 Statements
Python interpreter treats any text (either in interactive mode or in a
script) that ends with Enter key (translated as ‘\n’ and called
newline character) as a statement. If it is valid as per syntax rules