What is a Python Keyword?

Updated: May 18, 2020


A python keyword is a known as reserve word which can’t use as a name of your variable, class, function etc. These keywords have a particular meaning and they are used for particular purposes in Python programming language. For example – Python keyword “for” is used for “for loop” so we can’t name a variable with the name “for” else it may cause compilation error. There are total 33 keywords in Python 3.6.


Python keywords

False def if raise

None del import return

True elif in try

and else is while

as except lambda with

assert finally nonlocal yield

break for not

class from or

continue global pass

Example of Python keyword

Using while keyword to create a loop for displaying the values of variables num greater than 6.


num = 10 while num>6: print(num) num -= 1


Output:

10 9 8 7


6 views0 comments

Recent Posts

See All

Tell () function can be used to get the position of file handle and returns current position of file object where as Seek () function is used to change the position of the file handle to a given speci

Seek () function is used to change the position of the file handle to a given specific position in python. File handle such as a cursor which defines from where the data has to be read or written in t