An app registers users and must check the first name typed in. A name is allowed when it has more than 1 character and fewer than 15, and the app prints Name accepted for a good name and Name not accepted for a bad one. Figure 3 starts a test plan for this check. Another part of the app builds a username: it asks for the first and last names, uses the first 3 characters of a first name longer than 3 characters (otherwise the whole first name), adds the last name and shows the result. Figure 4 lists the statements, each with a numbered label, and Figure 4B is the empty flowchart frame to fill.
Choose the best statement of what validation is for.
Our own questions on this topic, marked straight away, so you see what to revise. Free now.
Show model answer for 04.1Hide model answer for 04.1
Validation checks that the input is sensible. It cannot prove the name is real or that the user is a person, only that the data is reasonable, for example that its length is allowed.
How the marks are earned
- The purpose is to test whether the data entered is sensible for the program to use.
- Choosing more than one option earns nothing.
Write a program that asks for a first name until its length is allowed, printing the right message each time, with meaningful variable names.
See how you would score on Iteration (Loops)Show model answer for 04.2Hide model answer for 04.2
valid = False
while not valid:
first_name = input("First name: ")
name_length = len(first_name)
if name_length > 1 and name_length < 15:
print("Name accepted")
valid = True
else:
print("Name not accepted")How the marks are earned
- An iteration structure is used that repeats until a name of an allowed length is entered (design mark).
- A string's length is worked out properly, at least once.
- At least one Boolean condition tests the name or its length against one of the two limits, even if the length is not coded correctly or is missing. Quotes round the numbers in this one condition are tolerated.
- All the length checks are made and combined correctly. Quotes round the numbers in this condition lose the mark.
- A name can be entered again inside the iteration structure.
- A structure prints the accepted message when the length is allowed and the rejected message otherwise, on every path through the program. Equivalent wording of a message is credited, and a faulty condition does not lose this mark if each message sits where it belongs.
- The case of the code is ignored; messages with the input statements are optional; gaps are ignored unless they change the logic.
- If the code has any error, the maximum is 5 marks.
- The design mark is for choosing a suitable technique and is credited whether or not the syntax is correct and whether or not the program works.
Why it scores
The while loop is the iteration and it keeps going until the flag valid becomes True. Inside it, len() finds the length and one condition joined with and checks both limits. A good name prints Name accepted and ends the loop. Any other name prints Name not accepted and the loop asks again.
Revise Iteration (Loops)Pick the option that explains what boundary test data is.
See how you would score on TestingShow model answer for 04.3Hide model answer for 04.3
Boundary data sits at the edge of the allowed range, on or just beside a limit. Wrong-type data is erroneous, and data the program expects is normal.
How the marks are earned
- Boundary data sits right on the edge of the range the program accepts.
- Choosing more than one option earns nothing.
How long could the test 2 name in Figure 3 be? Give a character count.
See how you would score on TestingShow model answer for 04.4Hide model answer for 04.4
1 character, or 15 characters. Allowed names have 2 to 14 characters, so 1 and 15 are the values just outside the limits that must be rejected.
How the marks are earned
- 1 or 15 characters.
- Giving both 1 and 15 is also accepted.
Name one type of test data, other than normal and boundary, that the test plan so far leaves out.
See how you would score on TestingShow model answer for 04.5Hide model answer for 04.5
Erroneous (invalid) test data. This is data the program should reject, such as data of the wrong type.
How the marks are earned
- Erroneous test data, also called invalid.
- A description of erroneous data, such as data of the wrong type, is also accepted.
- Minor spelling mistakes are ignored.
- Typical, extreme, boundary and normal are rejected.
Place the numbered statements of Figure 4 into the frame in Figure 4B so the flowchart builds the username.
See how you would score on Pseudocode & FlowchartsShow model answer for 04.6Hide model answer for 04.6
START
|
v
[1] firstName ← USERINPUT
|
v
[6] lastName ← USERINPUT
|
v
[2] LEN(firstName) > 3 ? -- no --> [3] username ← firstName + lastName
| |
yes |
v |
[5] username ← SUBSTRING(0, 2, firstName) + lastName |
| |
+-------------------------------------------------------------------+
|
v
[4] OUTPUT username
|
v
STOPHow the marks are earned
- Labels 1 and 6 come first, in either order, and label 4 is the final step after the decision.
- Label 2 is the decision, with one exit for yes and one for no.
- Label 5 is on the yes exit and label 3 is on the no exit, and both lead on to label 4.
- Any pseudo-code written next to a label is ignored. If the labels are left out, the exact statements from the figure are accepted instead.
Why it scores
Each arrow shows which step runs next. Both names are read first, then the decision label 2 splits the path into a yes branch and a no branch. A first name longer than 3 characters takes label 5 and keeps only its first 3 characters. Any other name takes label 3 and keeps all of it. Both branches meet again at label 4, which outputs the username.
Revise Pseudocode & Flowcharts