Uttar Pradesh, India
Instagram
image

Python Keywords & Identifiers

In this article, we are going to discuss keywords in python.

There are two types of keywords in python language are categorized

 

1-Pre-defined Keywords

2-Custom Keywords

 

 

1-Pre-defined Keywords

Pre-defined keywords are reserved keywords that have some meaning task in any programming language. These keywords are not used as any variable, class and any functions declaration.

like if,elif, set, and yield keywords.

 

Keywords in Python programming language

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 

 

2-Custom Keywords

Custom keywords are programmer-defined keywords that are used for declaring a variable, methods, and classes, etc.

 You can check pre-defined keywords programmatically using the below program

 

Step1: Open command prompt or terminal (Figure1)

Step 2: Type python

Step3: Type below keyword (Figure2)

>>> import keyword

>>> print(keyword.kwlist)

 

O/P:

['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', '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']

>>>

Fig.2
image


Comments

Share your thoughts in the comments

Your email address will not be published. Required fields are marked *