The coding stage

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

The coding stage

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What happens in the coding stage of the PDLC?
A The problem is first identified and the requirements are listed
B The design is turned into program code in a programming language
2. Which is the guide a programmer follows during the coding stage?
A The design, such as pseudocode or a flowchart
B The final test results
3. Which describes the correct order of the first three PDLC stages?
A Analysis, design, coding
B Analysis, coding, design
4. A programmer writes a very long program in one go and only runs it at the very end. Is this good practice in the coding stage?
A Yes, it saves time because you only need to test once
B No, code should be written in small parts and checked as you go
5. The design has the pseudocode line: INPUT Age. What should the programmer do in the coding stage?
A Write the matching line of code in the chosen programming language
B Change the design so it asks for a different value

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Coding stage AThe coding stage should follow the design. Ignoring the pseudocode or flowchart means the code may not match the plan.
2Build one sub-program at a time, then run it BThe third PDLC stage, where the design is turned into program code in a programming language
3The design is the guide: each pseudocode line becomes a line of program code CRequirement: reject marks over 100 -> IF Mark > 100 THEN
4Code is compared against the requirements to check it does what the user needs DCode should be written in small parts and checked as you go. Leaving all checking to the end makes errors hard to find.
5Start writing code before the design is finished and ignore the flowchart EOUTPUT "Enter a mark" becomes print("Enter a mark")
6Write the whole program in one go and only check it at the end FCode is written in small parts so each part can be checked before the next is added

Definitions

Coding stage

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
// Stage 3 of the PDLC: ______
2.
// Design: get the age from the user _____ Age
3.
// Design: add 1 to the count Count ← _____ + 1
4.
// Requirement: mark is 0 to 100 IF Mark >= 0 AND Mark __ 100 THEN
5.
// Design: repeat 5 times FOR Count ← 1 __ 5 NEXT Count

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A // Design: read two marks
B OUTPUT Mark1
C INPUT Mark2
D Total ← Mark1 + Mark2
Question 2
A // Requirement: find the average
B Total ← Mark1 + Mark2 + Mark3
C Average ← Total * 3
D OUTPUT Average
Question 3
A // Design: loop 5 times
B FOR Count ← 1 TO 5
C OUTPUT "Hello"
D ENDFOR
Question 4
A // Design: pass mark is 50
B IF Score >= 50 THEN
C OUTPUT "Pass"
D OTHERWISE
E OUTPUT "Fail"
F ENDIF
Question 5
A // Part 1: get the radius
B Radius ← INPUT
C // Part 2: find the area
D Area ← 3.14 * Radius ^ 2

Answer Key

The coding stage
Section A: Quick Questions
Q1
B — The design is turned into program code in a programming language
Q2
A — The design, such as pseudocode or a flowchart
Q3
A — Analysis, design, coding
Q4
B — No, code should be written in small parts and checked as you go
Q5
A — Write the matching line of code in the chosen programming language
Section B: Match the Pairs
Q1
Coding stage → The third PDLC stage, where the design is turned into program code in a programming language
Q2
Build one sub-program at a time, then run it → Code is written in small parts so each part can be checked before the next is added
Q3
The design is the guide: each pseudocode line becomes a line of program code → OUTPUT "Enter a mark" becomes print("Enter a mark")
Q4
Code is compared against the requirements to check it does what the user needs → Requirement: reject marks over 100 -> IF Mark > 100 THEN
Q5
Start writing code before the design is finished and ignore the flowchart → The coding stage should follow the design. Ignoring the pseudocode or flowchart means the code may not match the plan.
Q6
Write the whole program in one go and only check it at the end → Code should be written in small parts and checked as you go. Leaving all checking to the end makes errors hard to find.
Section C: Definitions
Q1
Coding stage — The third PDLC stage, where the design (pseudocode or flowchart) is turned into program code in a programming language, written step by step and checked against the requirements.
Section D: Fill in the Blanks
Q1
// Stage 3 of the PDLC: Coding
Q2
// Design: get the age from the user INPUT Age
Q3
// Design: add 1 to the count Count ← Count + 1
Q4
// Requirement: mark is 0 to 100 IF Mark >= 0 AND Mark <= 100 THEN
Q5
// Design: repeat 5 times FOR Count ← 1 TO 5 NEXT Count
Section E: Spot the Error
Q1
B — The design says the program must read two marks from the user. OUTPUT displays a value instead of reading one. The line should be INPUT Mark1.
Q2
C — The requirement says to find the average. An average is the total divided by the number of marks, so the code should use / 3 and not * 3.
Q3
D — A Cambridge pseudocode FOR loop is closed with NEXT and the loop variable, not ENDFOR. The line should be NEXT Count.
Q4
D — The flowchart's 'No' branch must be written with the keyword ELSE. OTHERWISE is not a Cambridge pseudocode keyword.
Q5
B — INPUT is a command that is followed by the variable name. It is not a value that can be assigned. Part 1 should be INPUT Radius, and it can be tested before Part 2 is written.