A program asks the user for a whole number and only accepts values from 1 to 100, including both ends. The program is being tested, and an algorithm has been written for it.
Tick one or more boxes against each value in Figure 1, to name its type or types of test data.
Our own questions on this topic, marked straight away, so you see what to revise. Free now.
Show model answer for 01.1Hide model answer for 01.1
27: Normal
"Hello": Invalid / erroneous
105: Invalid / erroneous
100: Boundary (and also Normal)
How the marks are earned
- One mark for each row, up to 4.
- 27: normal.
- "Hello": invalid or erroneous.
- 105: invalid or erroneous.
- 100: boundary, or boundary and normal together. Boundary alone is credited, and so is boundary with normal.
Why it scores
27 is a sensible value inside the range 1 to 100 and is not on an edge.
Text is the wrong type of data. The program wants a whole number.
105 is a number but it is above the largest value allowed, 100.
100 sits exactly on the edge of the allowed range, so it is boundary data. It is also accepted by the program, so ticking normal as well is credited.
Revise TestingComplete the algorithm in Figure 2 by filling the three numbered gaps so that 1 to 100 is accepted and other numbers are rejected.
See how you would score on Selection (IF Statements)Show model answer for 01.2Hide model answer for 01.2
Gap 1: >= 1
Gap 2: num <= 100
Gap 3: else
num = input("Enter a number between 1 and 100")
if num >= 1 AND num <= 100 then
print("accepted")
else
print("not accepted")
endifHow the marks are earned
- One mark for each gap, up to 3.
- BP1, gap 1: a check that num is at least 1; >= 1 or > 0 are both credited.
- BP2, gap 2: a check that num is at most 100. The form num <= 100 or num < 101 is credited. The variable num must appear in this check.
- The two checks may be written in either order, so the upper limit may come first.
- BP3, gap 3: else. An elseif or elif is credited only if it carries a full correct comparison, such as num < 1 OR num > 100.
- This is Section A, so wording such as less than or equal to is credited in place of the symbols.
Why it scores
The word num is already printed before the gap, so only the comparison is written here. The first AND condition rules out numbers below the bottom of the range. 1 itself must be allowed, so use >= and not >.
The second AND condition rules out numbers above the top of the range. 100 itself must be allowed, so use <= and not <. The condition has to name num again.
The else branch runs for every value that fails the check, so it prints the rejection message. Nothing needs to be compared here.
The finished algorithm. AND needs both checks to be true, so a number is accepted only when it is at least 1 and at most 100.
Revise Selection (IF Statements)Give an identifier for one variable that the completed algorithm uses.
See how you would score on Variables & ConstantsShow model answer for 01.3Hide model answer for 01.3
numHow the marks are earned
- num.
- Extra code around the name earns nothing. Capital letters and small spelling slips are ignored.
Give one Boolean operator that the completed algorithm uses.
See how you would score on Boolean ExpressionsShow model answer for 01.4Hide model answer for 01.4
ANDHow the marks are earned
- AND.
- Extra code around the operator earns nothing. Capital letters and small spelling slips are ignored.