Ease of reading and writing code: high-level vs low-level

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

Ease of reading and writing code: high-level vs low-level

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which statement about reading code is correct?
A Low-level code uses familiar words, so it is easier to read
B High-level code uses familiar words, so it is easier to read
2. To add two numbers and show the result, which is likely?
A One high-level line such as print(a + b)
B One low-level instruction does the whole job
3. A programmer writes the same program in a high-level language and in assembly language. Which version will usually have MORE lines?
A The assembly language version
B The high-level version
4. Why is low-level code hard to read?
A It is made of many detailed instructions that are not like everyday English
B It is written in plain English sentences
5. Which is true about mistakes when writing code?
A More instructions mean fewer chances to make a mistake
B More instructions give more chances to make a mistake

Match the Pairs

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

Left columnRight column
1total = a + b ALow-level code needs many instructions for one job, so it takes longer to write, not less time.
2LDA a / ADD b / STA total Bif score > 50: print("Pass")
3High-level code uses familiar English-like words, so a reader can understand what it does CThree low-level instructions that load, add and store to do the same job as one high-level line, so it takes longer to write and is harder to read
4Low-level code is hard to read because it is made of short, detailed instructions DOne high-level line that adds two numbers and stores the answer, using familiar words and symbols that are easy to read
5Low-level code is quicker to write than high-level code because it uses fewer instructions. ELDA 12 / CMP 50 / BRP 8 / OUT
6More instructions make code easier to get right, because there is less chance of mistakes. FMore instructions give more chances to make mistakes, so low-level code is more error-prone.

Definitions

high-level code

Fill in the Blanks

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

1.
total = price _ tax
2.
LDA price ___ tax STA total
3.
_____("Hello")
4.
LDA price ADD tax ___ total
5.
___ price ADD tax STA total

Spot the Error

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

Question 1
A a = 5
B b == 3
C print(a + b)
Question 2
A INP
B STA 10
C INP
D ADD
E OUT
F HLT
Question 3
A name = input("Name? "
B print("Hi " + name)
C print("Bye")
Question 4
A n = 3
B for i in range(n)
C print(i)
Question 5
A mark = 72
B if mark >= 50:
C print("Pass)
D else:
E print("Fail")

Answer Key

Ease of reading and writing code: high-level vs low-level
Section A: Quick Questions
Q1
B — High-level code uses familiar words, so it is easier to read
Q2
A — One high-level line such as print(a + b)
Q3
A — The assembly language version
Q4
A — It is made of many detailed instructions that are not like everyday English
Q5
B — More instructions give more chances to make a mistake
Section B: Match the Pairs
Q1
total = a + b → One high-level line that adds two numbers and stores the answer, using familiar words and symbols that are easy to read
Q2
LDA a / ADD b / STA total → Three low-level instructions that load, add and store to do the same job as one high-level line, so it takes longer to write and is harder to read
Q3
High-level code uses familiar English-like words, so a reader can understand what it does → if score > 50: print("Pass")
Q4
Low-level code is hard to read because it is made of short, detailed instructions → LDA 12 / CMP 50 / BRP 8 / OUT
Q5
Low-level code is quicker to write than high-level code because it uses fewer instructions. → Low-level code needs many instructions for one job, so it takes longer to write, not less time.
Q6
More instructions make code easier to get right, because there is less chance of mistakes. → More instructions give more chances to make mistakes, so low-level code is more error-prone.
Section C: Definitions
Q1
high-level code — Code that uses familiar words, so it is easier to read and write than low-level code, which needs many detailed instructions to do the same job.
Section D: Fill in the Blanks
Q1
total = price + tax
Q2
LDA price ADD tax STA total
Q3
print("Hello")
Q4
LDA price ADD tax STA total
Q5
LDA price ADD tax STA total
Section E: Spot the Error
Q1
B — A single = stores a value in a variable. == compares two values, and b does not exist yet. It should be b = 3. High-level code like this is easy to read, but one wrong symbol still breaks it.
Q2
D — In low-level code ADD needs an address to say which stored value to add. It should be ADD 10. Low-level code needs many small, exact instructions, so details like this are easy to miss.
Q3
A — The closing bracket is missing from input(). It should be name = input("Name? "). High-level code reads almost like English, and one line does the job of many low-level instructions.
Q4
B — A for loop line must end with a colon. It should be for i in range(n):. One high-level loop line replaces many low-level instructions, but the syntax must still be correct.
Q5
C — The string is missing its closing quote. It should be print("Pass"). Familiar words make high-level code easy to read, but the syntax must still be correct.