An online payment checker takes three inputs. A is true if the password typed is right, B is true if the PIN typed is right, and C is true if the card has been blocked. Output P is true when the user passes either check and the card is not blocked. In 05.4 no check that the digits are numeric is needed.
Draw the logic circuit in Figure 7 that gives output P from inputs A, B and C.
Our own questions on this topic, marked straight away, so you see what to revise. Free now.
Show model answer for 05.1Hide model answer for 05.1
P = (A OR B) AND NOT CHow the marks are earned
- One mark for each point, up to 3.
- BP1: an OR gate that has two inputs. Any OR gate with two inputs is credited.
- BP2: a NOT gate on input C.
- BP3: the OR gate output and the NOT gate output joined by an AND gate. This mark can follow through where sensible, for example if a NOT gate is missing or wrong, or the wrong gate was used instead of OR.
- Gate shapes must be correct: a NOT gate has a small circle, and AND and OR gates have no circle.
- A maximum of 2 marks if there are extra gates or the circuit does not work logically.
Why it scores
The drawn circuit written as one Boolean expression: A and B go into an OR gate, because either the password or the PIN is enough. C goes through a NOT gate, because the card must not be blocked. An AND gate needs both results to be true.
Revise Logic GatesComplete the truth table in Figure 8 for the output P of an AND gate with inputs A and B.
See how you would score on Truth TablesShow model answer for 05.2Hide model answer for 05.2
A B P
0 0 0
0 1 0
1 0 0
1 1 1How the marks are earned
- One mark for all four combinations of A and B: 00, 01, 10 and 11. They need not be in order.
- One mark for the P column: 1 for the one row where both inputs are 1, and 0 for the remaining three rows.
- T and F, yes and no, or ticks and crosses are credited in place of 1 and 0.
Why it scores
Two inputs give four combinations. AND is only true when both inputs are true, so only the last row has P = 1.
Revise Truth TablesDraw one line from each technique in Figure 9 to its correct example.
See how you would score on Computational ThinkingShow model answer for 05.3Hide model answer for 05.3
Abstraction to the third example
Decomposition to the first example
Algorithmic thinking to the fourth example
How the marks are earned
- One mark for each correct link, up to 3. A technique with more than one link earns nothing for it.
- Abstraction is linked to the third example box.
- Decomposition is linked to the first example box.
- Algorithmic thinking is linked to the bottom example box.
Why it scores
Abstraction keeps only the details that matter, here identity, PIN and password, and ignores all other data.
Decomposition splits a big problem into smaller parts, here a security module and a payments module.
Algorithmic thinking plans a step by step process, here the steps a user follows to pay safely. The second example, more RAM, is not a thinking technique at all.
Revise Computational ThinkingCreate an algorithm that reads the PIN typed in as a string, printing VALID PIN for four characters not 1234 or 4321, else INVALID PIN.
See how you would score on Input ValidationShow model answer for 05.4Hide model answer for 05.4
pin = input("Enter PIN")
if pin.length == 4 AND pin != "1234" AND pin != "4321" then
print("VALID PIN")
else
print("INVALID PIN")
endifHow the marks are earned
- One mark for each point, up to 6. This is Section A, so pseudocode, structured English or a flowchart can score, but the answer must not just repeat the question.
- BP1: the PIN is taken as input and stored or used.
- BP2: an attempt at selection, or at a condition controlled loop.
- BP3: a correct check that the PIN has 4 characters.
- BP4: a correct check that the PIN is not 1234 and not 4321. BP3 and BP4 may be one combined check, if it works, or two separate checks, and either may test for the good case or the bad case. Each comparison, with 1234 and with 4321, must name the variable.
- BP5: every invalid PIN produces INVALID PIN (once or several times), provided all three checks were sensibly attempted, even if VALID PIN is printed as well. A sensible but wrong attempt at BP3 and BP4 still counts.
- BP6: provided all three checks were sensibly attempted, VALID PIN is printed only for a fully valid PIN, with no contradictory output such as INVALID PIN as well. A sensible but wrong attempt at BP3 and BP4 still counts.
- & for AND, and | or || for OR, are accepted.
- Taking in or comparing the PIN as an integer gets benefit of the doubt. No quotation marks are needed round 1234 or 4321. Equivalent output messages are credited.
- A flowchart is read by its text and not its shapes.
Why it scores
The PIN is stored, then one if statement tests all three rules together. AND means every rule must pass, so VALID PIN is printed only for a good PIN. The else branch prints INVALID PIN for everything else, so the two messages never appear together.
Revise Input Validation