4.1.1
Identifiers
Identifiers
Identifiers
Identifiers are the names given to variables, constants, and subroutines.
Variables
Variables
- Variables should have lowercase names, with each word separated by an underscore. For example:
- this_is_my_variable
- user_money
- Variable should also have descriptive names, for example user_money is much better than this_is_my_variable.
Constants
Constants
- Constants should be named using the same rules as variables, but uppercase.
Subroutines
Subroutines
- Subroutines should have lowercase names, with each word separated by an underscore. For example:
- calculate_sum()
- get_user_id()
- Subroutines should have descriptive names where possible.
Global rules
Global rules
- In general, all identifiers should be descriptive.
- Characters which might be confused should be avoided, for example:
- 0 and O.
- 1 and l (lower case L).
1Introduction to Python
1.1Python
1.2Input & Output
1.3Data Types
1.4Variables & Constants
1.6Program Flow
2Data Structures
2.1Lists & Strings
2.2File Handling
3Modularity
3.1Subroutines
3.2Data Flow
4Good Practice
4.1Naming & Whitespace
4.2Comments
4.3Exceptions
Jump to other topics
1Introduction to Python
1.1Python
1.2Input & Output
1.3Data Types
1.4Variables & Constants
1.6Program Flow
2Data Structures
2.1Lists & Strings
2.2File Handling
3Modularity
3.1Subroutines
3.2Data Flow
4Good Practice
4.1Naming & Whitespace
4.2Comments
4.3Exceptions
Unlock your full potential with GoStudent tutoring
Affordable 1:1 tutoring from the comfort of your home
Tutors are matched to your specific learning needs
30+ school subjects covered