2.7.1 The accepted style conventions and how these are implemented to create readable and maintainable code Flashcards

1
Q

State:

2 reasons to use defined style conventions

A
  • Consistent format
  • Maintainability
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

State:

The current style convention for Python

A

PEP8 - Python Enhancement Proposal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

State:

4 things that PEP8 provides guidelines for

A

4 of:
* Naming conventions/styles
* Use of comments
* Use of white space
* The structure of the code
* Indentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

State:

Why it is not possible to enforce the PEP8 convention?

A

It is an open-source programming language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Fill The Blank:

Names in python must be ……….. and …………… to be easy to understand what they represent

Naming conventions

A

Logical, Sensible

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Fill The Blank:

Irrelevant or inappropriate ………. can make it difficult to locate ………. during maintanence or ……………….

Naming conventions

A

Names, Errors, Debugging

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

State:

Convention for constants

Naming conventions

A

Capital single letter, word or words with words seperated by underscores _

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

State:

Convention for functions

Naming conventions

A

Lowercase word or words with words seperated by underscores _

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

State:

Convention for module

Naming conventions

A

Short, lowercase word or words with words seperated by underscores _

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

State:

Convention for variable

Naming conventions

A

Lowercase signle letter, word or words with no whitespace or special characters and words seperated by underscores _

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

State:

Symbol used to start a comment in python

Use of comments

A

#

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Fill The Blank:

Comments make code easier to ……………… as the meaning of the code is explained

Use of comments

A

Maintain

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Fill The Blank:

Comments should not explain obvious elements of a program but explain ………… elements

Use of comments

A

Implicit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Fill The Blank:

White space helps code look less …………….. and helps with …………….. and understandibility.

Use of white space

A

Cluttered, Readability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

A

Elements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

State:

The PEP8 advice for use of white space when using operators, mathematical, relational or boolean

Use of white space

A

Single space each side

17
Q

Fill The Blank:

If an expression has multiple operators then PEP8 advises to use white space only on the ………… priority ……………

Use of white space

A

Lowest, Operators

18
Q

State:

2 things that the structure of code will have an impact on

The structure of code

A
  • Readability
  • Ease of maintanence
19
Q

State:

Max line length advised by PEP8

The structure of code

A

79 Characters - including comments (because it is easier to read text vertically)

20
Q

State:

4 examples of elements of code structure

The structure of code

A

4 of:
* White space
* Indentation
* Tabes or spaces
* Blank lines
* Line breaks