Page 190 - AI Ver 1.0 Class 10
P. 190
Keywords
Keywords have special meaning which are reserved by Python for special purposes and are not allowed to be
used as identifiers. They are case sensitive. 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 giving 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
Identifiers are the user-defined names of variables, lists, classes, functions, dictionaries, tuples, etc. which are
used to 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.
• They are case sensitive. Uppercase and lowercase letters are different.
• Identifiers can be of any length.
Some of the examples of valid identifiers are: Num1, First_Name, Value, Scores_FirstTerm.
Some of the examples of invalid identifiers are: 1stsubject, My name, #mobile, City&Code, and Pin Code.
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. Variable has:
• A name that follows the rules of identifier naming conventions and is case sensitive.
• A value that can be integer, float, string, boolean, etc.
Unlike other programming languages, variables in Python are not created before. They are created automatically
when a value is assigned to it using the assignment operator (=). A variable assigned with a value of one type
can be re-assigned a new value of a different type as shown below:
>>> a=9
>>>a
188 Touchpad Artificial Intelligence-X

