Python Keywords

Python keywords are reserved words in Python that should not be used as variable, constant, function name, or identifier in your code. Take note of these keywords if you don’t want to run into errors when you execute your program:

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  


Python Identifiers

A Python Identifier is a name given to a function, class, variable, module, or other objects that you’ll be using in your Python program. Any entity you’ll be using in Python should be appropriately named or identified as they will form part of your program.

Here are Python naming conventions that you should be aware of:

  • An identifier can be a combination of uppercase letters, lowercase letters, underscores, and digits (0-9). Hence, the following are valid identifiers: myClass, my_variable, var_1, and print_hello_world.
  • Special characters such as %, @, and $ are not allowed within identifiers.
  • An identifier should not begin with a number. Hence, 2variable is not valid, but variable2 is acceptable.
  • Class identifiers begin with an uppercase letter, but the rest of the identifiers begin in lowercase.
  • You cannot use Python keywords as identifiers.
  • You can use underscores to separate multiple words in your identifier.
  • Python is a case-sensitive language and this behavior extends to identifiers. Thus, Labor and labor are two distinct identifiers in Python.