Basic Python

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

First Python Program

Python Identifiers

A Python identifier is a name used to identify a variable, function, class, module or other objects. 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, Machine and machine are two different identifiers in Python.

Here are naming conventions for Python identifiers:

  1. Class names start with an uppercase letter. All other identifiers start with a lowercase letter.
  2. Starting an identifier with a single leading underscore indicates that the identifier is private.
  3. Starting an identifier with two leading underscores indicates a strongly private identifier.
  4. If the identifier also ends with two trailing underscores, the identifier is a language-defined special name.
Close Menu