Maintainability
1a: Allows other programmers to understand the logic/purpose of the code (1) so they can update/fix it without breaking it (1).
1b: Indentation / Meaningful Variable Names / Use of Subprograms / Constants
2:
hours = float(input(...)) (1)
rate = float(input(...)) (1)
pay = hours * rate (1)
score is changed to 2.
3a: Start
End
3b: End
3c: In A, Line 04 is part of the IF block (dependent on condition) (1).
In B, Line 04 is outside the IF block (runs sequentially/always) (1).
draw_square().
4a:
def draw_square(): (1)
# Code for one square indented inside (1)
draw_square() (1)
4b: You only need to update the code in one place (the function definition) (1). The change automatically applies to every time the function is called (1).
3.14 is used in 50 different places throughout the 1000-line code.
3.14 manually in every calculation.
3.14 as a constant named PI, and write one example line showing how to use it in a calculation.
5a: If the value of Pi needs to change, the programmer has to find/replace it 50 times (1). High risk of missing one or making a typo (1).
5b: PI = 3.14 (1)
area = PI * (radius * radius) (1)