Keywords and Identifiers in Python

Keywords and Identifiers in Python
Identifiers in Python – The Python language has many similarities to Perl, C, and Java. However, there are some definite differences between the languages.

Identifiers in Python

A Python identifier is a name used to identify a variable, function, class, module or other object. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9).Python does not allow punctuation characters such as @, $, and % within identifiers. Python is a case sensitive programming language. Thus, Manpower and manpower are two different identifiers in Python.Here are naming conventions for Python identifiers −Class names start with an uppercase letter. All other identifiers start with a lowercase letter.Starting an identifier with a single leading underscore indicates that the identifier is private.Starting an identifier with two leading underscores indicates a strongly private identifier.If the identifier also ends with two trailing underscores, the identifier is a language-defined special name.

Keywords in Python

The following list shows the Python keywords. These are reserved words and you cannot use them as constant or variable or any other identifier names. All the Python keywords contain lowercase letters only.There are 33 keywords in Python 3.7. This number can vary slightly over the course of time.All the keywords except True, False and None are in lowercase and they must be written as they are. The list of all the keywords is given below.

Things to Remember

Python is a case-sensitive language. This means, Variable and variable are not the same.Always give the identifiers a name that makes sense. While c = 10 is a valid name, writing count = 10 would make more sense, and it would be easier to figure out what it represents when you look at your code after a long gap.Multiple words can be separated using an underscore, like this_is_a_long_variable.That was all from Keywords and Identifiers in Python.

Leave a Reply

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