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.
- 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.
- Python is a case-sensitive language and this behavior extends to identifiers. Thus, Labor and labor are two distinct identifiers in Python.
- You cannot use Python keywords as identifiers.
- Class identifiers begin with an uppercase letter, but the rest of the identifiers begin in lowercase.
- You can use underscores to separate multiple words in your identifier.
Variables in Python
- Another concept that might be familiar to you is variables. If math makes you queasy, don’t worry: variables in Python are easy to understand.
- A variable is basically a name that represents (or refers to) some value.
- A variable is like a container that stores values that you can access or change.
- It is a way of pointing to a memory location used by a program.
- You can use variables to instruct the computer to save or retrieve data to and from this memory location.
- A variable is a means of storing a piece of information using using a descriptive name.