Menu

6.1 Develop code

Card 1 of 33 0 got it 0 still learning
Question
TapClick or press space to see the answer
Answer
All 33 cards in this set
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
In Python, how is a single line comment started?
With the # symbol
Why should a programmer add comments to a program?
To explain what the code does to other programmers
A program contains comments on several lines. What happens to these comments when the program is translated and run?
They are ignored by the translator
Why is indentation used in a program?
To show which statements belong to the same block
A program uses the variable names a, b and c to store a length, a width and an area. Which change would make the program easier to understand?
Rename the variables so they describe what they store
What is the benefit of leaving blank lines between sections of a program?
It separates groups of statements so the code is clearer
A program mixes its input, processing and output statements in no particular order. Which change would improve the layout of the program?
Group related statements together into clear sections
A team of programmers read through each other's code to find errors and suggest improvements. What is this called?
A code review
A development team keeps an audit trail when they update their program. Why is this useful?
To record who changed the code and when
Why does it matter that a program is written so that it is easy to read and understand?
Other programmers can maintain and update it more easily
Which term describes the text added to a program to explain what the code does, which is ignored when the program is run?
Comments
What is meant by indentation?
Moving lines of code inwards from the left margin
What is the name for writing variable and subprogram names that describe what they store or do?
Meaningful identifiers
What is meant by white space?
Using blank lines and spaces to separate parts of a program
Which term describes the way the sections of a program are arranged and set out on the page?
Layout
A program has a comment on every line, such as 'add one to the score' next to the statement 'score = score + 1'. Why is this poor practice?
They repeat what the code already says
A development team reads through each other's code before releasing an update. What is the main benefit of doing this?
Faults and poor practice are spotted by another programmer
A programmer is adding a comment to the top of a new program. Which comment is most useful for other programmers?
What the program does and who wrote it