0% found this document useful (0 votes)
30 views10 pages

Unit 8 Assessment

Uploaded by

rappidofc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views10 pages

Unit 8 Assessment

Uploaded by

rappidofc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Assessment test: Unit 8 Logic and languages

Name: Cycle: Target:


1. (a) Give the names of the following logic gates:

Name: ___________ [1]

Name: ___________ [1]

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

(b) Give the Boolean expression equivalent to the logic diagram.

1
Assessment test: Unit 8 Logic and languages

2. A product type in a computer company is “HARDWARE”, “SOFTWARE” or “MANUAL”.


The following pseudocode algorithm is being written to validate user input.
productType = input("Please enter product type: ")

A if ______________________________________

______________________________________

then
print("valid product type entered")
else
print("product type invalid")
endif

(a) Complete the condition for the IF statement at A.


(b) The following incomplete algorithm performs an alternative validation check on a
product code.
(i) Insert the missing lines at B and C.
productID = input("Please enter ProductID: ")
validID = True
B _________________________

if productID.length != 6 then
validID = False
productID = input("ProductID invalid - Please re-
enter: ")
else
validID = True
endif
C _________________________

(ii) What type of validation check is carried out by the algorithm?

(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

4. A subroutine is given below.


function calc(x, y)
while x != y
if x > y then
x = x – y
else
y = y – x
endif
endwhile
return x
endfunction

(a) The subroutine is called as follows:


calc(36,30)

Complete the trace table below for the function call.

x y x != y

36 30 True

State the value that will be returned by the function: _____________________

(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)

"HEY" KHB Valid tests uppercase letters

"XYZ123@"

123

"X"

6. (a) Complete the table below to indicate whether each of the following
statements are True or False.

True or False?

All programs have to be converted to machine code


before they can be executed
A compiler translates a high-level language into machine
code
An interpreter converts a low-level language into
machine code

High-level languages are “machine-independent”

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. Programmers usually use an IDE (Integrated Development Environment) to develop their


programming code.
Some features offered by IDEs include breakpoints, stepping through code and watching
variables.
(a) Describe how an IDE can be used to debug programs that have logical
errors in them.

8
Assessment test: Unit 8 Logic and languages

(b) Explain two other features offered by IDEs.

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

What sections do you need to review again?

Where do you place yourself on the Learning Hierarchy at the end of the unit
based on your assessment?

10

You might also like