Keywords, Identifiers and Variables in Python

In this topic, we will focus on various Python keywords and their identifiers. This is the beginning to learn a new programming language as a beginner. Some basic theory is necessary to learn or stat with any programming language.  First, we will list down all the keyword names and familiar with the identifiers. So let’s start.

Python Keywords

Python has numerous keywords. Those are known as reserved words. These keywords cannot be used as function names, variable names, or others. Python has 33 keywords and these keywords are similar to the English language. So that beginners can understand it quickly. They can easily grape the purpose of each keyword used in Python. The list of keywords and its description is given below,

Keyword Description
And It is a logical operator
as It is used to create an alias
assert It is used to debug the code
Break It is used to break a loop
class It is used to define a class
continue It is used to skip the current iteration
def It is used to create a function
del It is used to delete an object
elif It is known as else if & conditional statement
else It is used in a conditional statement
Except It is used when an exception occurs
False It is a Boolean operator
Finally Executed without focusing any exception
for It is a loop
From It is used to import a module
Global It is used to state a global variable
if It is a conditional statement
Import It is used to import a module
In It is used for availability checking
Is It is used to check the variable equality
Lambda It is used to create an unsigned function
None It is used to represent a null value
Nonlocal It is used to state a non-local variable
not It is a logical operator
Or It is a logical operator
Pass It is a statement that has no action
Raise It is used to raise an exception
return It is used to return a value from a function
True It is a Boolean value
Try It is used to make a try of a block of code
While It is a loop
With It is used to solve exception handling
yield It is used to retune a generator

Python Identifiers

In simple words, Python identifiers are nothing but the variable name. It has a few rules for utilization. The rules are as follows

  • The identifiers always start with either alphabet or underscore (_). Example: number=1, _value=100, etc.
  • The identifiers cannot start with numeric values. Example: 1num, 3total, etc.
  • The identifiers cannot have any special characters like #, $, @, etc. A variable name can be created only with alphabets, numeric values, and underscore. 
  • Identifiers in Python are case sensitive. So, Python will treat value and VALUE as two different words.
  • Keywords cannot be used as identifiers. Example: global=10.

Code Example is given below:

number = 5

print(number)

#It will print 5

@k=6

print(@k)

#it will give an error

_ab = 30

print(_ab)

#It will print 30

00r=60

print(00r)

#it will give an error

xy_z = 50

print(xy_z)

#It will print 50

if=5

print(if)

#it will give an error

So we have to keep in mind all these points while we will do coding. Otherwise, we will surely get errors. It will be overcome with the practice. So keep practicing and we will back with a new module in Python.