30 min read
~260 words
Beginner
Prerequisites: None
Updated September 2026

Keywords, Identifiers and Variables

In a Nutshell

This section deals with concepts such as keywords, identifiers and variables

Keywords

Keywords in any programming language (including Python) are used to define its 'syntax' and 'structure'. Keywords in python are reserved for exclusive use of the compiler, and therefore, can-not be used as any identifier including variable names, function names, class names, and so on.

Note that keywords are case sensitive. The complete list of Python keywords are as follows:-

List of all "keywords" in Python

anddelfromnotWhile
aselifglobalorWith
assertelseifpassYield
breakexceptimportprint
classexecinraise
continuefinallyisreturn
defforlambdatry

Identifiers

The "names" given to various entities used in a script, such as variables, functions, classes and so on, are called "identifiers"

Rules for writing identifiers in Python

  1. An identifier can be a combination of lowercase letters (a to z), uppercase letters (A to Z), digits (0 to 9) or an underscore (_). Examples are:- myName, _myname, myname1 and so on.
  2. An identifier must not start with a digit. '1stName' is invalid, but 'Name1' is ok.
  3. Special symbols, such as @,$,!,#,% etc. cannot be used in identifier.
  4. You cannot use Python keywords as identifiers. Hence, you cannot use print, import, break as variable names.
  5. Python is a case-sensitive language. Therefore, 'myVariable' and 'Myvariable' are not the same.

Some good identifiers naming conventions are

  1. One should name identifiers that make sense. While n = 10 is valid. Writing number = 10 would make for more readable code and easier to figure out on a later date.
  2. It is good naming convention to separate multiple words with underscores. For example my_age is a valid identifier.
  3. We can also use camel-case style of writing, that is, capitalize every first letter of the word except the initial word. Thus my_age in camel case would be myAge.