Unit 8 Assessment
Unit 8 Assessment
Name:___________ [1]
(b) Complete the following truth table for the circuit shown.
INPUT A
R T
INPUT B
S
INPUT C
A B C R S T
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
1
Assessment test: Unit 8 Logic and languages
A if ______________________________________
______________________________________
then
print("valid product type entered")
else
print("product type invalid")
endif
if productID.length != 6 then
validID = False
productID = input("ProductID invalid - Please re-
enter: ")
else
validID = True
endif
C _________________________
(iii) Name one other type of validation check that could be carried out on
the product code.
2
Assessment test: Unit 8 Logic and languages
3
Assessment test: Unit 8 Logic and languages
3. The following is an incomplete algorithm for checking that a user has entered the correct
password. The password entered is to be checked against the password “ABCdef123”
The user is given 3 attempts to get the password correct before being logged out.
passwordOK = False
attemptsAllowed = 3
attempts = 0
while attempts <= attemptsAllowed and NOT passwordOK
if passwordOK then
print("Welcome back")
else
print("Logged out")
endif
Complete the algorithm.
4
Assessment test: Unit 8 Logic and languages
x y x != y
36 30 True
(b) State the value that will be returned by the following function call:
calc(18,4)
Value returned:________________
(c) State the purpose of the program.
5
Assessment test: Unit 8 Logic and languages
5. Emma is writing a subroutine to encrypt a string taken as a parameter. Only letters and
spaces can be encrypted. Each letter in the text is replaced by the letter three places further
down the alphabet. A is replaced by D, b by e, … Y by B, z by c. Spaces are not changed.
The program does not accept numbers or punctuation.
Emma is undertaking incremental testing and wishes to test the subroutine. Complete
the test plan below by stating, for each input, the expected outcome, the type of test
and a reason for the test. The first row has been completed for you.
Type of test (valid,
Expected
Input invalid, borderline, Reason for test
outcome
erroneous)
"XYZ123@"
123
"X"
6. (a) Complete the table below to indicate whether each of the following
statements are True or False.
True or False?
6
Assessment test: Unit 8 Logic and languages
(b) Give three reasons why a programmer might choose to use a high-level language
rather than a low-level language to write a program.
(c) Give two reasons why a programmer might choose to use a low-level language rather
than a high-level language to code a program.
7
Assessment test: Unit 8 Logic and languages
7. The pseudocode below shows an algorithm that is supposed to calculate the average of a
set of scores held in the array scores. The program contains two logic errors.
1 totalScore = 0
2 Array score[5]
3 score = [25, 17, -5, 28, 30]
4 for i = 0 to score.length
5 totalScore = totalScore + score[i]
6 next i
7 averageScore = totalScore / score.length - 1
Identify the two lines with logic errors in the above pseudocode, and write correct
versions of each so that the program will work as intended.
8
Assessment test: Unit 8 Logic and languages
Total: / 60
9
Assessment test: Unit 8 Logic and languages
Self-Review
After going through the answers and making corrections using purple pen please
complete the WWW & EBI
WWW:
EBI
Where do you place yourself on the Learning Hierarchy at the end of the unit
based on your assessment?
10