2.7.1 The accepted style conventions and how these are implemented to create readable and maintainable code Flashcards
State:
2 reasons to use defined style conventions
- Consistent format
- Maintainability
State:
The current style convention for Python
PEP8 - Python Enhancement Proposal
State:
4 things that PEP8 provides guidelines for
4 of:
* Naming conventions/styles
* Use of comments
* Use of white space
* The structure of the code
* Indentation
State:
Why it is not possible to enforce the PEP8 convention?
It is an open-source programming language
Fill The Blank:
Names in python must be ……….. and …………… to be easy to understand what they represent
Naming conventions
Logical, Sensible
Fill The Blank:
Irrelevant or inappropriate ………. can make it difficult to locate ………. during maintanence or ……………….
Naming conventions
Names, Errors, Debugging
State:
Convention for constants
Naming conventions
Capital single letter, word or words with words seperated by underscores _
State:
Convention for functions
Naming conventions
Lowercase word or words with words seperated by underscores _
State:
Convention for module
Naming conventions
Short, lowercase word or words with words seperated by underscores _
State:
Convention for variable
Naming conventions
Lowercase signle letter, word or words with no whitespace or special characters and words seperated by underscores _
State:
Symbol used to start a comment in python
Use of comments
#
Fill The Blank:
Comments make code easier to ……………… as the meaning of the code is explained
Use of comments
Maintain
Fill The Blank:
Comments should not explain obvious elements of a program but explain ………… elements
Use of comments
Implicit
Fill The Blank:
White space helps code look less …………….. and helps with …………….. and understandibility.
Use of white space
Cluttered, Readability
Fill The Blank:
If code contains too much white space then it can be difficult to understand which ……………… of code should be read together
Use of white space
Elements
State:
The PEP8 advice for use of white space when using operators, mathematical, relational or boolean
Use of white space
Single space each side
Fill The Blank:
If an expression has multiple operators then PEP8 advises to use white space only on the ………… priority ……………
Use of white space
Lowest, Operators
State:
2 things that the structure of code will have an impact on
The structure of code
- Readability
- Ease of maintanence
State:
Max line length advised by PEP8
The structure of code
79 Characters - including comments (because it is easier to read text vertically)
State:
4 examples of elements of code structure
The structure of code
4 of:
* White space
* Indentation
* Tabes or spaces
* Blank lines
* Line breaks