Ease of debugging: high-level vs low-level

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

Ease of debugging: high-level vs low-level

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which language level is generally easier to debug?
A High-level language
B Low-level language
2. What does debugging mean?
A Finding and fixing errors in a program
B Translating a program into machine code
3. Why can errors hide in a low-level program?
A It is always shorter than a high-level program
B It is often very long, with many small instructions
4. Which line is easier to read when looking for a mistake?
A total = price * quantity
B LDA 25 MUL 26 STO 27
5. Which statement is true about error messages from translators?
A They are usually clearer for low-level code
B They are usually clearer for high-level code

Match the Pairs

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

Left columnRight column
1total = price * qty AA short, readable high-level line, so a mistake in it is easy to spot and fix
2LDA 20 ADD 21 STA 22 BLine 4: NameError: name 'totl' is not defined
3Debugging means finding and fixing errors in a program CTiny instructions make the program much longer and harder to read, so errors are harder to find, not easier.
4A translator gives a clearer error message for high-level code, so it is quicker to fix DLow-level code where each step does very little, so a long program hides errors and is harder to debug
5A student says: 'Low-level code is easier to debug because every instruction is tiny.' EReadable, shorter code makes errors easier to spot, and translators give clearer messages for it.
6A student says: 'High-level code is harder to debug because it is written in words.' Fprint(totl) # fix: print(total)

Definitions

easier to debug

Fill in the Blanks

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

1.
# Easy to read, so easy to debug total = price _ qty
2.
LDA price ___ qty STA total
3.
# Short line: error is easy to spot _____(total)
4.
# Readable loop: easy to debug _____ count > 0: count = count - 1
5.
# Translator reports the line number name = _____("Name? ")

Spot the Error

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

Question 1
A total = 0
B for n in range(5)
C total = total + n
D print(total)
Question 2
A LDR price
B ADD tax
C STA total
D OUT
E HLT
Question 3
A name = input('Name: ')
B age = int(input('Age: '))
C print(name + ' is ' + age)
Question 4
A score = 40
B if score >= 50:
C prnt('Pass')
D else:
E print('Fail')
Question 5
A loop LDA count
B SUB one
C STA count
D BRP lop
E HLT

Answer Key

Ease of debugging: high-level vs low-level
Section A: Quick Questions
Q1
A — High-level language
Q2
A — Finding and fixing errors in a program
Q3
B — It is often very long, with many small instructions
Q4
A — total = price * quantity
Q5
B — They are usually clearer for high-level code
Section B: Match the Pairs
Q1
total = price * qty → A short, readable high-level line, so a mistake in it is easy to spot and fix
Q2
LDA 20 ADD 21 STA 22 → Low-level code where each step does very little, so a long program hides errors and is harder to debug
Q3
Debugging means finding and fixing errors in a program → print(totl) # fix: print(total)
Q4
A translator gives a clearer error message for high-level code, so it is quicker to fix → Line 4: NameError: name 'totl' is not defined
Q5
A student says: 'Low-level code is easier to debug because every instruction is tiny.' → Tiny instructions make the program much longer and harder to read, so errors are harder to find, not easier.
Q6
A student says: 'High-level code is harder to debug because it is written in words.' → Readable, shorter code makes errors easier to spot, and translators give clearer messages for it.
Section C: Definitions
Q1
easier to debug — Debugging is finding and fixing errors. It is easier in short, readable high-level code than in long, hard-to-read low-level code, and translators give clearer error messages for it.
Section D: Fill in the Blanks
Q1
# Easy to read, so easy to debug total = price * qty
Q2
LDA price MUL qty STA total
Q3
# Short line: error is easy to spot print(total)
Q4
# Readable loop: easy to debug while count > 0: count = count - 1
Q5
# Translator reports the line number name = input("Name? ")
Section E: Spot the Error
Q1
B — The colon is missing at the end of the for line. Python's translator points straight at line 2 with a clear message, which is why short high-level code is easy to debug. It should be: for n in range(5):
Q2
A — LDR is not a valid mnemonic here. The load instruction is LDA. In a long assembly program, one wrong mnemonic is hard to find, and the assembler's message is short and unhelpful.
Q3
C — age is an integer, and you cannot join a number to text with +. Python reports a clear TypeError on this line. Fix it by using commas: print(name, 'is', age).
Q4
C — The function name is misspelled. Python reports a clear NameError that names prnt on line 3, so the error is easy to find in readable high-level code. It should be: print('Pass').
Q5
D — The branch uses a label that does not exist; it should be BRP loop. The assembler only reports an undefined label. In a program with hundreds of low-level lines, finding the typo is much harder than in high-level code.