In this tutorial, you will learn about keywords (reserved words in Python) and identifiers (names given to variables, functions, etc.).
Keywords
are the reserved words in Python. It is also known as reserved words.
A keyword in a programming language is defined as which has a fixed meaning and cannot be redefined by the programmer or used as identifiers.
In Python, keywords are case sensitive.
There are 35 keywords in Python. This number can vary slightly over the course of time.
All the keywords except True, False and None are in lowercase and they must be written as they are. The list of all the keywords is given below.
False | await | else | import | pass |
None | Break | except | in | raise |
True | class | finally | is | return |
and | continue | for | lambda | try |
as | def | from | nonlocal | while |
assert | del | global | not | with |
async | elif | if | or | yield |
We can get the above list by using help() in Python Shell
An identifier is a name given to entities like class, functions, variables
, etc. It helps to
differentiate one entity from another.
m@n='Raj'
print(m@n)
m@n='Raj'
^
SyntaxError: cannot assign to operator
pi
and Pi
are two different identifiersclass = 'vehicle'
Output
class = 'vehicle' ^ SyntaxError: invalid syntax
As we discussed above ,Python is a case-sensitive language. This means, Class
and class
are not the same.
Try to name the identifiers which makes sense.Give simple and understandable name to the identifier. While am = 2
is a valid name.
You can also use multiple words for an identifier's name but use underscore(_)
to diffrentiate between them, like this_is_a_car_vehicle
.