Python Keywords and Identifiers

Python Keywords and Identifiers


In this tutorial, you will learn about Identifiers (names given to variables, functions, etc.) and keywords (basically these are reserved words in Python).

Python Keywords

  • Keywords are the reserved words in Python.
  • We cannot use a keyword as a function name or a variable name or any other identifier. They are used to define the structure and syntax in the Python language.
  • In Python, keywords are case sensitive.



There are 33 keywords in Python 3.7:


  • All the keywords except some those are TrueFalse and None are in lowercase.
  • They must be written in the same way they are. 

The Complete list of all the keywords is given below:
  1. True
  2. False
  3. None
  4. and
  5. as
  6. assert
  7. async
  8. await
  9. break
  10. class
  11. continue
  12. def
  13. del
  14. elif
  15. else
  16. except
  17. finally
  18. for
  19. from 
  20. global
  21. if
  22. import 
  23. in
  24. is
  25. lambda
  26. nonlocal
  27. not
  28. or
  29. pass
  30. raise
  31. return
  32. try
  33. while
  34. with
  35. yield



If you want to have an overview of Keywords, here is the complete list of all the keywords with examples.


Python Identifiers

The identifier is a name given to entities like variables, class, functions, etc. It helps to differentiate between one entity from another.

Rules for writing identifiers:

  • Identifiers can be the combination of letters in Uppercase (A to Z) ,in lowercase (a to z), digits (0 to 9) or can be an underscore _
    • Names like myClassroll_no_1 and print_this_to_screen, all are valid example.
  • An identifier cannot start with a digit.
    •  1variable is invalid, but 
    • variable1 is a valid name.
  • Keywords cannot be used as identifiers.



  • We cannot use special symbols like !, @, #, $, % etc. in our identifier.



  • The identifier can be of any length.



Most Important Things to Remember:

  • Python is a case-sensitive language. 
  • This means identifier and Identifier are not the same.
  • Always give the identifiers a name that makes some sense which should be easily understood. While df = 10 is a valid name but writing roll_no= 10 would make more sense, and it would be easier to figure out what our code represents.
  • Multiple Numbers of words can be separated using an underscore, like this_is_a_called_identifiers.

Comments