Identifier
A python identifier is a user-defined name that represents a variable, function, class, module, or any other object. If you specify a name for a programmable entity in Python, it is technically an identifier. The Python language sets a set of rules for programmers to create meaningful identifiers.
- The first character must be a letter in the alphabet or an underscore _.
- The other parts of the identifier are made up of letters, numbers, and underscores.
- Identifiers are case sensitive.
Reserved words
Reserved words are keywords, and we cannot use them as any identifier names. Python's standard library provides a keyword module that can output all the keywords for the current version:
>>> Import keyword
>>> keyword.kwlist
[' False ', ' None ', ' True ', ' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' fi Nally ', ' for ', ' from ', ' global ', ' if ', ' import ', ' in ', ' was ', ' lambda ', ' nonlocal ', ' not ', ' or ', ' Pass ', ' raise ', ' return ', ' Try ', ' while ', ' with ', ' yield ']
Comments
The single-line comment in Python begins with # , with the following example:
# First comment Print ("Hello, python! ")
Execute the above code and the output is:
Hello, python!.
Multiline comments can be in multiple # numbers, plus "and" " (3 single quotes or three double quotes):
# First comment # a second comment " " Third note Fourth Note " " """ Fifth Note, sixth comment """
Print ("Hello, python!")
Execute the above code and the output is:
Hello, python!.
Python basic syntax