Font size
WorksheetsIG CS P2 review
Total questions: 151
Worksheet time: 1hrs 24mins
Choose all the Boolean logic gates ...
NOT
AND
BUT
XOR
Truth table for AND gate?
Truth table for OR gate?
Which logic gate is this truth table for?
AND
OR
NOR
XOR
Which of these programming constructs make use of Boolean logic?
if ... then ...
while ... do ....
repeat ... until ....
repeat n times ....
If x = 3 and y = 5, choose all the statements that evaluate to True.
x < y
y > x**2
2 * x == y
y % x == 3
Evaluate: 2 < 3 And ( Not 3 > 2)
True
False
Result of this Boolean expression?
True
False
Which word best completes this sentence:
A logic gate is a tiny electronic component on a chip that has inputs and ______ to simulate a Boolean operation.
output
result
data
processing
Which word best completes this sentence?
A combination of logic gates is known as a logic _______.
circuit
program
array
truth table
Output for input of 150?
Discount of 10% is 15.0
Discount of 5% is 7.5
No discount
Invalid input
Output for input of ""?
Invalid password
Password is too short
Password is too long
Password is Ok
Output for inputs of 750 and 22900
Sufficient profit made this week
Income in line with attendance this week
Attendance is very low this week
Possible accounting error
Inputs for output of "Sufficient profit made this week"
income = 4501, attendance = 499
income = 2500, attendance = 22500
income = 1000, attendance = 1000
income = 500, attendance = 2500
A logic gate that outputs True only if both its inputs are also True?
OR
AND
XOR
NAND
Which logic gate is the odd one out and for which reason?
OR - because it's more likely to output True
AND - because it has more than two inputs
XOR - because the probability of it outputting True or False is equally likely
NAND - because it is the inverse of AND
Which of these are fundamental control structures in any computer program?
branching
sequence
selection
repetition
iteration
For which algorithm would it be best to use a conditional loop?
Finding largest number in a list
Calculating average of a list of numbers
Counting occurrences of an item in a list
Checking if an item is in a list
What would the list [9, 6, 12, 7, 3, 16, 10] look like after one iteration of the Bubble sort algorithm (smallest to biggest)?
[6, 9, 7, 3, 12, 10, 16]
[3, 9, 6, 12, 7, 16, 10]
[3, 6, 7, 9, 10, 12, 16]
[9, 6, 12, 3, 7, 16, 10]
Which is the correct flowchart symbol for input/output?
This is the main loop from an algorithm (shown in Python.) Which algorithm is it?
LInear search
BInary search
Bubble sort
Count occurrences
This is the main loop from an algorithm (shown in Python.) Which algorithm is it?
Linear search
Binary search
Bubble sort
Merge sort
A classification of how data is stored and displayed, and of which operations that can be performed on the stored value
data type
data value
data
data packet
A persistent structured collection of data that allows people to extract information in a way that meets their needs
record
table
database
basedata
The values associated with each record in a database table
table
record
primary key
field
An SQL command that identifies the table to use
SELECT
FROM
WHERE
ORDER BY
An SQL command that sorts the results from a query by a given column either alphabetically or numerically
SUM
WHERE
COUNT
ORDER BY
A field in a database that uniquely identifies a record
public key
private key
primary key
secondary key
A collection of fields that describe one item
table
record
field
database
An SQL command that fetches specified fields (columns) from a table
SELECT
FROM
WHERE
ORDER BY
A list of SQL commands that perform a given task, often stored in a file so it can be reused
original scripts
SQL Scripts
storyboard scripts
screenplay scripts
The standard query language for writing scripts to obtain useful information from a relational database
Hypertext Markup Language (HTML)
Data Manipulation Language (DML)
Data Definition Language (DDL)
Standard Query Language (SQL)
Decomposition describes the process of...
Explaining how your program works
Code becoming difficult to test as it gets larger
Breaking a large problem into smaller pieces
Testing a program
Which of these is not a method used in the design stage of the program lifecycle?
Python
Pseudocode
Structure Diagram
Flowchart
What is a variable?
A special character or word in a programming language that identifies an action to be performed
A positive or negative whole number that can be used with mathematical operators
A named data store that contains a value that does not change during the execution of a program
A named data store that contains a value that may change during the execution of a program
What is a constant?
A named data store that contains a value that does not change during the execution of a program
A special symbol or word in a programming language that identifies an action to be performed
A named data store that contains a value that may change during the execution of a program
A positive or negative whole number that can be used with mathematical operators
What is an array?
A set of programming statements grouped together under a single name that can be called to perform a task in a program
A positive or negative whole number that can be used with mathematical operators
A data structure containing several elements of the same data type
A variable or constant that is several characters in length
What does the DIV operator do in programming?
To generate a random number
To round a value to a given number of decimal places
To return the quotient (whole number part) of a division
To return the remainder of a division
What is the purpose of the ROUND library routine in programming?
To generate a random number
To return the quotient (whole number part) of a division
To return the remainder of a division
To round a value to a given number of decimal places
What is the purpose of the RANDOM library routine in programming?
To return the remainder of a division
To generate a random number
To return the quotient (whole number part) of a division
To round a value to a given number of decimal places
What is the purpose of the AND operator in programming?
To perform logical AND operation on two boolean values
To combine two numbers together
To multiply two numbers
To divide two numbers
What is the purpose of a loop in programming?
To store data in a file and retrieve data from a file
To repeat a set of instructions multiple times
To declare, use, identify appropriate data types for, read and write arrays with one and two dimensions
To group programming statements together under a single name that can be called to perform a task in a program
What is the purpose of the NOT operator in programming?
To reverse the value of a boolean variable
To perform addition of two numbers
To perform division of two numbers
To perform multiplication of two numbers
What is the purpose of the XOR operator in programming?
To perform exclusive OR operation on two boolean values
To combine two numbers together
To multiply two numbers
To divide two numbers
What is the main purpose of a subroutine in programming?
To group programming statements together under a single name that can be called to perform a task in a program
To declare, use, identify appropriate data types for, read and write arrays with one and two dimensions
To perform calculations using arithmetic operators
To store data in a file and retrieve data from a file
Which of the following is a correct way to declare a variable in Python?
int number = 5
number = 5
var number: 5
let number = 5
What data type is used to represent true or false values in Python?
Integer
String
Boolean
Float
What will be the output of the following code? print(10 - 2 * 3)
4
1
16
8
Which of the following operators is used for integer division in Python?
/
//
%
**
How can you read user input in Python?
input("Enter something: ")
read("Enter something: ")
get("Enter something: ")
scan("Enter something: ")
Which of the following statements is true about the following code? age = 16 if age >= 18: print("Adult") else: print("Minor")
It will print "Adult".
It will print "Minor".
It will cause an error.
It will print nothing.
How many times will the following loop run? for i in range(4): print(i)
4 times
3 times
5 times
Infinite
What is the purpose of the else statement in a conditional structure?
To execute code when the condition is true
To execute code when the condition is false
To terminate the program
To handle errors
Which of the following is a valid way to define a function in Python?
function greet():
def greet[]:
def greet():
function greet():
What is the output of the following code? string = "Hello" print(string.lower())
hello
Hello
HELLO
Error
Which of the following statements correctly checks if x is equal to 5?
if x = 5:
if x == 5:
if (x = 5):
if x === 5:
What will the following code output? x = 3 while x < 6: print(x) x += 1
3, 4, 5
3, 4, 5, 6
3, 4, 5, 6, 7
3, 4
Which of the following is a valid Boolean expression?
5 + 5
x > y
x and y
Both B and C
What will be the output of the following code? for i in range(1, 5): print(i)
1, 2, 3, 4
1, 2, 3, 4, 5
0, 1, 2, 3, 4
1, 2, 3, 4, 5
Which statement is used to define a constant in Python?
const PI = 3.14
define PI 3.14
PI = 3.14
#PI = 3.14
Which of these is not a code data type
integer
boolean
text
character
Which of these is not a database data type
string
number
yes/no
currency
text
Which line of pseudocode has a logical error when inputting 50 numbers and totalling/outputting the sum of those numbers that were under 100.
total <- 0
FOR count <- 1 TO 50
PRINT "next number?"
INPUT num
IF num <= 100
THEN
total <- total + num
ENDIF
NEXT count
OUTPUT "The total of matching numbers was:", total
total <- 0
FOR count <- 1 TO 50
IF num <= 100
total <- total + num
OUTPUT "The total of matching numbers was:", total
What would the fifth entry in the total column be in a trace table on a dry-run of the pseudocode shown below if the inputted numbers started with 64, 36, 103, 24, 102, 107, 15, 23, 84, …
total <- 0
FOR count <- 1 TO 50
PRINT "next number?"
INPUT num
IF num <= 100
THEN
total <- total + num
ENDIF
NEXT count
OUTPUT "The total of matching numbers was:", total
124
226
231
139
15
Which of these statement type match ups is incorrect?
Iteration: FOR count <- 1 TO 100 …. NEXT COUNT
Totalling: x <- x + 1
Assignment: name <- "Fred"
Output: PRINT total
Selection: CASE OF x …. OTHERWISE… ENDCASE
Tabitha wants to find the largest number in an array of 30 integers called Nums. On what line has she made a mistake?
maxIndex <- 1
FOR i <- 1 TO 30
IF Nums[i] > Nums[maxIndex]
THEN
maxIndex <- Nums[i]
ENDIF
NEXT i
PRINT "The maximum number was: ", Nums[maxIndex]
Line 1
Line 2
Line 3
Line 5
Line 8
Which two validation checks would be most suitable to check someone's AGE
Length check
Check digit
type check
range check
What is happening to the 'positives' variable here?
positives = 0
FOR I <- 1 TO 10 DO
INPUT num
IF num > 0
THEN
positives = positives + 1
ENDIF
NEXT I
OUTPUT "there were", positives, "positive numbers"
totalling
iteration
counting
sequencing
selection
How would you declare an array of 10 items?
pointless(1:10)
pointless(1-10)
pointless[1:10]
pointless[1-10]
pointless <- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Which principles is being used here?
INPUT Grade
CASE OF Grade
9: PRINT "Well done, great job"
8: PRINT "Well done, great job"
7: PRINT "Got to still feel pleased"
6: PRINT "Room for improvement"
OTHERWISE: PRINT "summer hols soon"
ENDCASE
iteration
selection
sequencing
totalling
counting
Which data type is for decimal numbers in coding?
integer
boolean
real
unreal
Which of these two extracts could use more effective code?
IF num > 12 OR num < 6
THEN
PRINT "valid"
ELSE
PRINT "invalid"
ENDIF
----------
num = 1
REPEAT
PRINT num * 2
num = num + 1
UNTIL num = 20
extract 1
extract 2
What uniquely identifies a record in a table?
A field
A primary key
A query
A criteria
Verification is done ...
so that it is the correct data type
so that data entered exactly matches the original source
Define ABSTRACTION
Breaking a task into smaller tasks.
Drawing a map to show how to reach a destination.
Creating step by step instructions.
Focusing on what is important and ignoring what is unnecessary.
What is abstraction?
The process of filtering out unnecessary detail
The process of filtering out irrelevant characteristics
The process of filtering out irrelevant characteristics and unnecessary detail
What is decomposition?
Breaking down a complex problem or system into smaller, more manageable parts
Adding detail to make a problem more complex
When you ignore the unnecessary detail in a problem
Why do we decompose a complex problem?
To make it more difficult to solve
To change the problem we have
To make it easier to solve
Which of these is an example of decomposition?
Watching a mechanic repair a bicycle
Looking at different bicycles for similarities between them
Finding out how a bicycle works by looking in detail at the different parts that make up the bicycle
A boolean is...
A whole number
A number with a decimal part
Letters, numbers or punctuation
True or False
An integer is...
A whole number
A number with a decimal part
Letters, numbers or punctuation
True or False
A real is...
A whole number
A number with a decimal part
Letters, numbers or punctuation
True or False
A string is...
A whole number
A number with a decimal part
Letters, numbers or punctuation
True or False
The best data type for an age is...
integer
real
string
boolean
The best data type for a name is...
integer
real
string
boolean
The best data type for an average is...
integer
real
string
boolean
The best data type for a counter is...
integer
real
string
boolean
8.2 is a...
integer
real
string
boolean
"Hello" is a...
integer
real
string
boolean
If a grade of 98 was inputted, what would be the output?
Passed
Failed
Else
If the grade of 60 was input, what would be the output?
Passed
Failed
Else
If the grade of 12 was input, what would be the output?
Passed
Failed
Else
What would the program output with the following inputs?
Payrate - 12
Hours Worked - 10
12
Final pay
OUTPUT
120
This program is meant display the phrase "Coding is cool" multiple times.
Fill in the blank.
INPUT
WHILE
OUTPUT
LOOP
Fill in the blank
OUTPUT
ENDIF
THEN
INPUT
Complete the blank:
" (a) is the process of repeating an action multiple times."
What is missing?
____ i = 1 To 10
OUTPUT: "String"
ENDFOR
FOR
FOUR
WHILE
Fill in the missing blank:
_______ variable <> "Hi"
OUTPUT: "Hi to you!"
ENDWHILE
WHILST
WHILE
FOR
IF
Which of the following will run 10 times? (Choose all that apply.)
FOR i = 1 TO 10
OUTPUT: "Number " + i
ENDFOR
FOR i = 0 To 10
OUTPUT: "Number: " + i
ENDFOR
input = 10
count = 1
WHILE count <= input
OUTPUT: count
count = count + 1
ENDWHILE
Which index is label C pointing to?
7
8
9
What field is best validated using a format DD/MM/YYYY
Customer ID
Date of Birth
Post code
This is an example of a
Range check
Lookup check
Format check
Presence check
An error message saying "The pupil must be aged between 11 and 16" is an example of a
Range check
Lookup check
Format check
Presence check
What validation type checks a minimum number of characters have been entered?
Format check
Length check
Range check
What is a primary key?
A field that links to another table
A filed that has values from multiple tables
A field that holds unique values
A filed that has repeating values
What would this out put? print(users[2][1])
error
16
brown
smith
What would this out put? print(users[0][0])
smith
ben
sam
james
What is considered erroneous data?
No data being given when one is expected
Data of the incorrect data type
Data of the correct type but outside the accepted validation checks
Data which should be accepted by a program without causing errors
What type of data should be rejected by a computer system?
Boundary data
Normal data
Invalid data
Erroneous data
Which operator tells you the remainder of a division?
/
MOD
DIV
//
Which operator gives the whole number from a division?
MOD
DIV
//
/
Which operator means "equal to" in Pseduocode?
==
=
<--
<>
22 MOD 5
1
2
3
4
17 DIV 7
2
3
4
1
20 _ _ _ 5 = 0
MOD
DIV
=
ADD
(15 NOT 7) OR (6 DIV 2 = 3)
TRUE
FALSE
What does the round function in Python do?
The round function in Python rounds a number to a specified number of decimal places or to the nearest whole number.
The round function in Python returns the square root of a number.
The round function in Python generates a random number between two given numbers.
The round function in Python converts a number to a string.
What is the result of round(3.14159, 2)?
3.13
3.15
3.14
3.1
numbers = [1,2,3,4,5]
What is the result of len([numbers])?
1
10
5
15
Data type for '12/4/16'
Text
Date
Long text
Number
Data type for 'Bob'
Number
Memo
Text
Currency
Data type for 'male/female'
Yes/No
Text
Number
Currency
Data type for 'CV34 5TR'
Text
Number
Date
Autonumber
Name that logic gate! (Use all CAPS)
(a)
Name that logic gate! (Use all CAPS)
(a)
Name that logic gate! (Use all CAPS)
(a)
Which logic gate is this truth table for?
NOR
NAND
XOR
AND
What is the truth table of
AND gate?
What is the truth table of
OR gate?
What is this logic gate?
AND
OR
NOT
XOR
What is this logic gate?
AND
OR
NOT
XOR
What would the OUTPUT(x) be in the following scenario:
A = 1
B = 0
C= 0
0
1
What is the OUTPUT in the logic diagram?
0
1
