Knowledge organisersTesting
Syntax errors as errors which break the grammatical rules of the programming language and stop it from being run/translated; Logic errors as errors which produce unexpected output;
Syntax errors break the grammatical rules of a programming language and stop the program from running or being translated. Logic errors allow the program to run but produce incorrect or unexpected results. Identifying both types of error is a key skill that requires careful testing and code review.
printt), missing brackets, missing colons, missing quotation marks, using =< instead of <=, print(Not in demand) — missing string delimiters.total = num1 + num1 instead of total = num1 + num2 — using wrong variable is a logic error (line 03).if total >= 10 then — only checks one boundary; should be if total >= 10 AND total <= 20 then — incomplete condition is a logic error (line 04).for scoreCount = 1 to scores.length - 1 misses index 0; should start at 0. And scores[scoreCount] = total + total should be total = total + scores[scoreCount].if stocklevel >= 5 or =< 25 has THREE errors: or→AND, =<→<=, missing variable name in second comparison. Also print(Not in demand) needs quotation marks. Also output messages are swapped.# SYNTAX ERROR examples:
# print("Hello" <- missing closing bracket
# if x == 5 <- missing colon
# pritn("Hi") <- misspelled keyword
# print(Not in demand) <- missing string quotes
# LOGIC ERROR examples:
# total = 0 inside a loop (resets each iteration)
# print("empty") prints the word, not the variable
# for i in range(1, 9) misses index 0 of an array
for i in range(9): # Correct: starts from 0
total = total + room[i]