Page 286 - AI Ver 1.0 Class 9
P. 286
Tokens
Tokens are the smallest meaningful unit of a program. Python supports the various tokens. Let us learn about
them.
Keywords
Words that have special meaning are reserved by Python for special purposes and are not allowed to be used
as identifiers. We can see the list of the reserved keywords by giving the following command at the python
command prompt:
>>> import keyword
>>>keyword.kwlist
Following is the list of keywords displayed by running the above commands:
False class finally is return
None continue for lambda try
True def from nonlocal while
and del global not with
as elif if or yield
assert else import pass
break except in raise
Identifiers (Names)
Identifiers are the user-defined names of variables, list, dictionary, tuples, classes etc. They identify an element
in Python.
Naming the identifiers follows rules as given below:
• An identifier can have letters in uppercase or lowercase, numbers or underscore(_).
• It cannot begin with a number or an underscore.
• No special characters like $, period(.), space, etc. are allowed.
• It should not be a Python keyword.
• Uppercase and lowercase letters are different.
Example of invalid identifiers are:
First name : Spaces not allowed.
Last&Name : Cannot have special character.
_class9th : Cannot begin with underscore.
9thclass : Cannot begin with number
else : Keyword not allowed.
Example of valid identifiers are:
Myclass, class9, Address, address, first_name, city, student_id, data123, _class9th
Variables
Variable is a name given to a memory location to hold a specific value. It is just like a container that can hold any
type of data that can be changed later in the program.
284 Touchpad Artificial Intelligence-IX

