The ease with which a programmer can understand what the code does
A program stores a value under a name, and that value is given a new value several times while the program runs. Which term describes that name?
Variable
What is meant by maintainability in a program?
How easily the code can be changed later without introducing mistakes
A program begins with the line PI = 3.142. The value is used in calculations later but is never given a new value while the program runs. Which term describes PI?
A constant
What is meant by a naming convention for constants?
An agreed way of writing constant names, such as using capital letters
Which of these describes a constant in a program?
A named value that does not change while the program runs
Which line sets a constant for the number of lives at the start of a game, following the Python convention?
MAX_LIVES = 3
A line inside a Python program gives a constant a new value. What happens when the program runs?
The new value is used, because Python allows the change
Where should a constant be set in a program?
Once, near the top of the program
A program uses the name VAT for the value 0.2 in a calculation. Why does this make the program easier to understand?
The name VAT shows what the value 0.2 means
A programmer types the value 0.2 into five different calculations. How does using a constant help prevent mistakes?
The value is written once, so it cannot be typed differently later
A program uses the constant PASS_MARK = 40 to check exam scores. The pass mark changes to 50. What must the programmer do?
Change the value on the line where PASS_MARK is set
A student's program uses the fixed value 3.142 in three different calculations. What should the student do?
Declare a constant PI once and use PI in every calculation
During the game, lives is reduced by one each time the player loses. Which statement about this program is correct?
MAX_LIVES is a constant and lives is a variable
A program records the results of a quiz. Which value should be stored as a variable rather than a constant?
The current score of the player
A program asks the user to type in the weight of a parcel, then works out the cost of posting it. Which statement about the weight is correct?
It is a variable because it can be different each time the program runs
A program contains the line VAT = 0.2 near the top. Where does the value 0.2 come from?
It was written into the code by the programmer
A programmer writes DAYS_IN_WEEK = 7 at the top of a program. Why is a constant the right choice for this value?
The value stays the same for the whole run of the program
We use cookies to enhance your experience. You can manage your preferences or learn more in our Cookie Policy.