4.1.1
Identifiers
Identifiers
Identifiers
Identifiers are the names given to variables, constants, and subroutines.
![Illustrative background for Variables](https://image-v2.cdn.app.senecalearning.com/2018-07/050c73a9-e0c2-4651-b3f6-54dd46acdf0d/RAM-Random-Access-Memory-Computer-,h_400,q_80,w_640.jpg)
![Illustrative background for Variables ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-07/050c73a9-e0c2-4651-b3f6-54dd46acdf0d/RAM-Random-Access-Memory-Computer-,h_400,q_80,w_640.jpg)
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.
![Illustrative background for Constants](https://image-v2.cdn.app.senecalearning.com/2018-05/d02fc304-19d2-4611-a75e-08d788b5e2cd/letters-656514_960_720,h_400,q_80,w_640.png)
![Illustrative background for Constants ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-05/d02fc304-19d2-4611-a75e-08d788b5e2cd/letters-656514_960_720,h_400,q_80,w_640.png)
Constants
Constants
- Constants should be named using the same rules as variables, but uppercase.
![Illustrative background for Subroutines](https://image-v2.cdn.app.senecalearning.com/2018-09/e3db2cf8-61a4-43d4-804a-45efd9569613/flow-diagram,h_400,q_80,w_640.jpg)
![Illustrative background for Subroutines ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-09/e3db2cf8-61a4-43d4-804a-45efd9569613/flow-diagram,h_400,q_80,w_640.jpg)
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.
![Illustrative background for Global rules](https://image-v2.cdn.app.senecalearning.com/2018-09/d4d7be69-e7c0-4540-94bf-fd7f5e635625/moon-earth-space-,h_400,q_80,w_640.jpg)
![Illustrative background for Global rules ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-09/d4d7be69-e7c0-4540-94bf-fd7f5e635625/moon-earth-space-,h_400,q_80,w_640.jpg)
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
![Go student ad image](/en-GB/revision-notes/_next/image?url=%2Fen-GB%2Frevision-notes%2Fimages%2Fgo-student-uk-ad.jpg&w=640&q=100)
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