Python TutorialsProgramming

A Basic Guide To Keywords In Python

Keywords In Python

What are Keywords in Python?

The keywords are some predefined and reserved words in python that have special meanings. Keywords are used to define the syntax of the coding.

The keyword cannot be used as an identifier, function, or variable name. All the keywords in python are written in lower case except True and False.

There are 33 keywords in Python 3 let’s go through all of them one by one.

Keywords in Python

1. and

This is a logical operator it returns true if both the operands are true else return false.

2. Or

This is also a logical operator it returns true if anyone’s operand is true else return false.

3. not

This is again a logical operator it returns True if the operand is false else return false.

4. if

This is used to make a conditional statement.

5. elif

The elif statement is executed if the previous conditions were not true.

6. else

Else is used with if and elif conditional statement the else block is executed if the given condition is not true


This is created for a loop.

8. while

This keyword is used to create a while loop.

9. break

This is used to terminate the loop.

This is used to create an alternative.

11. def

It helps us to define functions.


It is used to define the anonymous function.


This is a null statement that means it will do nothing.


It will return a value and exit the function.

15. True

This is a boolean value.

16. False

This is also a boolean value.

17. try

It makes a try-except statement.

18. with

The with keyword is used to simplify exception handling.


This function is used for debugging purposes. Usually used to check the correctness of code.


It helps us to define a class.


It continues to the next iteration of a loop


It deletes a reference to an object.

23. except

Used with exceptions, what to do when an exception occurs

24. finally

Finally is used with exceptions, a block of code that will be executed no matter if there is an exception or not.

25. global

This declares a global variable.

26. from

The from is used to import specific parts of any module.

27. import

This is used to import a module.

28. in

It’s used to check if a value is present in a list, tuple, etc, or not.

This is used to check if the two variables are equal or not.

30. raise

This raises an exception.

31. yield

It ends a function and returns a generator.

32. nonlocal

It’s declared a non-local variable.

33. None

This is a special constant used to denote a null value or avoid. It’s important to remember, 0, any empty container (e.g empty list) do not compute to None.


Python is a great programming language for beginners. With its core syntax being easy to learn, it helps users write simple and clean code. Additionally, the wide array of libraries available makes Python an ideal candidate for both small and large projects alike. If you want to learn more about Python or start writing some code with it, head over to our blog today!  If you have a project that you’d like me to work on, please let us know on Telegram.


Hi there! I am the Founder of Cyber World Technologies. My skills include Android, Firebase, Python, PHP, and a lot more. If you have a project that you'd like me to work on, please let me know: [email protected]

Leave a Reply

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

Back to top button