Naming Rules and Conventions
There are several rules for naming variables in Python. These are the following:
- a variable name must start with a letter or the underscore character, which means a variable name can not begin with a number.
- a variable name may contain only English letters, numbers, and underscore characters.
- variables names are case sensitive, i.e.,
Chapter
,chapter
, andCHAPTER
will be considered by Python as three different objects.
Above we considered the 'technical' side of naming variables. At the same time, there are several conventions between programmers on namings. These are:
- variables names should be in lowercase.
- variables names containing several words should have words separated by the underscore characters (
_
).
These rules are not compulsory but are recommended. For example, if you need to store the number of user's points, it will be much better to use
points
,num_of_points
, orn_points
namings instead ofn
,p
, or something like these.
Merci pour vos commentaires !
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Posez-moi des questions sur ce sujet
Résumer ce chapitre
Afficher des exemples du monde réel
Awesome!
Completion rate improved to 2.7
Naming Rules and Conventions
Glissez pour afficher le menu
There are several rules for naming variables in Python. These are the following:
- a variable name must start with a letter or the underscore character, which means a variable name can not begin with a number.
- a variable name may contain only English letters, numbers, and underscore characters.
- variables names are case sensitive, i.e.,
Chapter
,chapter
, andCHAPTER
will be considered by Python as three different objects.
Above we considered the 'technical' side of naming variables. At the same time, there are several conventions between programmers on namings. These are:
- variables names should be in lowercase.
- variables names containing several words should have words separated by the underscore characters (
_
).
These rules are not compulsory but are recommended. For example, if you need to store the number of user's points, it will be much better to use
points
,num_of_points
, orn_points
namings instead ofn
,p
, or something like these.
Merci pour vos commentaires !