what is identifier ? Variables naming rules | Python Programming for Absolute Beginners in Hindi #0
in this tutorial we will learn about identifiers in python programming language , naming rules and its best practices
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.
Python Valid Identifiers Example
abc123
abc_de
_abc
ABC
abc
Python Invalid Identifiers Example
123abc
abc@
123
for
Python Identifier Naming Best Practices:-
Only class names are started with capital letters (Student, Employee).
Multiple words in a variable are separated by an underscore (is_valid()).
If an identifier begins with an underscore, it means it is a private identifier. This does not make the variable private. It is only for the ease of the programmer to easily distinguish between private variables and public variables.
Python built-in magic methods use double underscores around the names (__len__). Therefore, double underscores are used only when you are dealing with mangling in Python.
Using longer name than one character is always preferred (index = 1 is better than i = 1).
Camel case are used while naming the variables (studentAddress, studentId). Camel case use a capital letter to begin the second word in a compound name or phrase, when it is not separated from the first word by a space.
LinkedIn:
https://www.linkedin.com/in/engr-taju..
.
Github:
https://github.com/usta-cyber
Email:
engr.tajummalhussain@gmail.com
#identifiers #python #naming rules #pythonbeginners #python_best_practices
Видео what is identifier ? Variables naming rules | Python Programming for Absolute Beginners in Hindi #0 автора Питоновый космос
Видео what is identifier ? Variables naming rules | Python Programming for Absolute Beginners in Hindi #0 автора Питоновый космос
Информация
2 декабря 2023 г. 9:03:51
00:12:25
Похожие видео