A line of code reads print('Hello with a missing closing bracket and quote. What type of error is this?
A syntax error
A program divides the number of cakes by the number of people. It is run with 20 cakes and 0 people. Which type of error occurs?
A runtime error
A program contains several syntax errors. What must happen before the program can run?
Every syntax error must be corrected
A program should find the area of a square from its side length but contains the line area = length * 2. How should this logic error be corrected?
Replace the line with area = length ** 2
Why can a logic error be harder to find than a syntax error?
The program still runs, so the compiler does not report it
A programmer adds print statements at several points in a program to help find a logic error. Why does this help?
It shows the value held in each variable
A program should award a pass when a score is 50 or more, but it uses if score > 50. Which change corrects this logic error?
Replace it with if score >= 50
What is meant by a syntax error?
An error where the code breaks the rules or grammar of the language so it cannot be translated into machine code
What is meant by a logic error?
An error where the program runs without stopping but does not do what the programmer intended
What is the name for a table used to record the value of each variable as a program runs, line by line, so that a logic error can be found?
Trace table
What is meant by a runtime error?
An error that only occurs while the program is running, such as trying to divide a number by zero
Which type of error is reported by a compiler before the program can be run?
A syntax error
What is meant by debugging a program?
Finding and correcting the errors in a program
A program divides the number of cakes by the number of people. It works for most inputs but stops when the number of people is 0. Which change corrects the runtime error?
Check that the number of people is not 0 before dividing
A program will not run and the compiler reports an error on line 12. What should the programmer do first?
Look at line 12 to find the mistake in the code
We use cookies to enhance your experience. You can manage your preferences or learn more in our Cookie Policy.