Font size
WorksheetsPaper 2 J277 June 2022 Revision OCR
Total questions: 149
Worksheet time: 2hrs 32mins
What is the purpose of an if statement in programming?
To repeat a block of code multiple times
To make decisions based on conditions
To define a function
To declare a variable
Which of the following is the correct syntax for an if statement in Python?
`if x > 10 then:`
`if (x > 10) {`
`if x > 10:`
`if x > 10`
What will be the output of the following code? ```python x = 5 if x > 3: print("Hello") else: print("Goodbye") ```
Goodbye
Hello
Error
Nothing
Which of the following loops is best suited for iterating over a list in Python?
while loop
for loop
do-while loop
foreach loop
What is the output of the following code? ```python for i in range(3): print(i) ```
1 2 3
0 1 2 3
0 1 2
1 2
Which of the following is true about while loops?
They always execute at least once
They execute as long as a condition is true
They are used to iterate over a list
They are the same as for loops
What will be the output of the following code? ```python x = 0 while x < 3: print(x) x += 1 ```
1 2 3
0 1 2 3
0 1 2
1 2
Which of the following is an example of a nested loop?
A loop inside a function
A loop that runs indefinitely
A loop inside another loop
A loop with an if statement
Which of the following is the correct way to break out of a loop in Python?
exit
break
continue
stop
What will be the output of the following code? ```python for i in range(3): if i == 1: break print(i) ```
0 1 2
0 1
0
1 2
What is the purpose of the continue statement in a loop?
To exit the loop
To skip the current iteration and continue with the next
To pause the loop
To restart the loop
What will be the output of the following code? ```python for i in range(3): if i == 1: continue print(i) ```
0 1 2
0 1
0 2
1 2
Which of the following is true about nested loops?
The inner loop runs once for each iteration of the outer loop
The outer loop runs once for each iteration of the inner loop
Both loops run independently
Nested loops are not allowed in Python
Choose the correct data type:
"initial of a first name"
Character
String
Integer
Real/Float
Boolean
Choose the correct data type:
"Sarah"
Character
String
Integer
Real/Float
Boolean
Choose the correct data type:
"Resolution"
Character
String
Integer
Real/Float
Boolean
Choose the correct data type:
True
Character
String
Integer
Real/Float
Boolean
Choose the correct data type:
yes / no
Character
String
Integer
Real/Float
Boolean
Choose the correct data type:
6
Character
String
Integer
Real/Float
Boolean
Choose the correct data type:
-900
Character
String
Integer
Real/Float
Boolean
Choose the correct data type:
0.25
Character
String
Integer
Real/Float
Boolean
Choose the correct data type:
240.00
Character
String
Integer
Real/Float
Boolean
What is OUTPUT?
1
0
What is OUTPUT?
1
0
What is OUTPUT?
1
0
What is OUTPUT?
1
0
What is OUTPUT?
1
0
What is OUTPUT?
1
0
What is OUTPUT?
1
0
What is OUTPUT?
1
0
What type of logic is this table showing:
AND
OR
NOT
NOR
What type of logic is this table showing:
AND
OR
NOR
XOR
"I will take my umbrella only if it is both about to rain and I can find it"
This is an example of which type of logic?
AND
OR
NOT
NOR
"The burglar alarm will go off if either the door or the window or both are opened". This is an example of which type of Logic?
AND
OR
NOT
NOR
What type of gate is this?
AND
OR
NOT
NOR
In this logic circuit, what is Q if the inputs are: A=0, B=1, C=0?
0
We can't say
1
What is the boolean expression for this logic circuit?
A OR B AND C = Q
Q = (A AND B) OR C
Q = A OR (B AND C)
Q = (A OR B) AND C
Which is the truth table for the AND gate?
What is the boolean expression for this logic circuit?
Q = NOT (A OR B)
Q = NOT A AND B
NOT A OR B = Q
Q = (NOT A) OR B
The trace table will contain two columns: (a) and Output.
Look at the Algorithm Below. In the corresponding Trace Table, what value should 'A' be?
1
3
5
7
Look at the Algorithm Below. In the corresponding Trace Table, what value should 'B' be?
1
3
5
7
Look at the Algorithm Below. In the corresponding Trace Table, what value should 'C' be?
1
3
8
13
Look at the Algorithm Below. In the corresponding Trace Table, what value should 'D' be?
11
13
8
1
Look at the Algorithm Below. In the corresponding Trace Table, what value should 'E' be?
3
5
8
13
Look at the Algorithm Below. In the corresponding Trace Table, what value should 'F' be?
5
8
13
18
What is the purpose of using a Trace table?
Planning before writing a program
To help debug a program
Check for spelling mistakes
Understand the program more
The trace table will contain three columns: n, (a) , and Output.
This loop will repeat (a) times
What are logic errors?
An error that does not stop the code from executing
When the logic gates are incorrectly connected
An error where the logic doesn't make sense
Code that does not give the desired output
Which loop loops a set number of times?
for
while
infinite
loopy
Repeating a task multiple times in programming is known as ?
Iterators
Scope
Looping
In programming, what is iteration?
The repetition of steps within a program
The order in which instructions are carried out
A decision point in a program
Testing a program to make sure it works
FOR loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
Which type of loop iterates until instructed otherwise?
FOR loop
WHILE loop
What is the purpose of comments in Python programming?
Comments in Python programming are used to explain the code logic, make the code more readable, and provide additional information to other developers.
Comments in Python programming are used to store data
Comments in Python programming are used to create loops
Comments in Python programming are used to execute code
How do you denote a single-line comment in Python?
// This is a single-line comment
/* This is a single-line comment */
# This is a single-line comment
''' This is a single-line comment '''
What is the symbol used to start a comment in Python?
!
//
/*
#
Why are comments important in programming?
Comments provide clarity and context to the code.
Comments reveal sensitive information about the code.
Comments are only for experienced programmers and not beginners.
Comments are unnecessary and slow down the code execution.
What are variables in Python?
Variables in Python are identifiers that can hold different types of data such as numbers, strings, lists, etc.
Variables in Python are reserved keywords that cannot be changed
Variables in Python are used to perform mathematical operations only
Variables in Python are not necessary for writing code
How do you declare a variable in Python?
value = variable_name
variable_name : value
variable_name = value =
variable_name = value
What are the rules for naming variables in Python?
Variable names in Python can only contain letters, numbers, and underscores. They cannot start with a number and cannot be a reserved keyword. Variable names are case-sensitive.
Variable names in Python can start with a number
Variable names in Python must be at least 10 characters long
Variable names in Python can contain special characters like @, $, and %
Can variable names start with a number in Python?
No
Yes
Sometimes
Maybe
What is the difference between declaring and initializing a variable?
Declaring a variable is specifying its type and name, while initializing a variable is assigning a value to it.
Declaring a variable is assigning a type to it, while initializing a variable is specifying its value.
Declaring a variable is assigning a value to it, while initializing a variable is specifying its type and name.
Declaring a variable is specifying its value, while initializing a variable is assigning a type to it.
Why is it important to choose meaningful variable names?
Meaningful variable names are only important for beginners
Meaningful variable names increase the file size of the code
Meaningful variable names make the code run faster
Meaningful variable names improve code readability, understandability, and maintainability.
If I want to store multiple names in variables, which of the following would be good variable names in best practice?
a
b
c
name1
name2
name3
Audrey
Ben
John
blah1
blah2
blah3
If I want to store my name in a variable, which of the following would be a good variable name in best practice?
name
teacher
mister
abcdef
If I want to store my height in a variable, which of the following would be a good variable name in best practice?
abcdefg
inches
number
height
Look at the following code:
name = "John"
age = "23"
What type of data is stored in the variable age?
str
int
float
nothing
Look at the following code:
name = "John"
age = 23
What type of data is stored in the variable age?
str
int
float
nothing
Look at the following code:
name = "John"
age = 23
What type of data is stored in the variable name?
str
int
float
nothing
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
Which of the following is a general characteristic?
Dogs run quickly
This dog has a wet nose
This dog has a brown coat
Which of the following is a general characteristic?
This boat has an engine
Some boats have sails
This boat is blue
Which of the following is NOT a general characteristic?
Dogs run quickly
Dogs have a nose
This dog has a brown coat
When drawing a dog, which of the following characteristics could be ignored?
Dogs run quickly
Dogs have paws
Dogs have a nose
To be able to draw cars, which of the following characteristics is it necessary to know about?
Who owns them
Who sells them
If they have wheels
Houses have walls, doors and people live in them. How many of these characteristics do we need to know to draw a house?
One
Two
Three
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
Which of these is an example of decomposition?
Breaking the problem of organising a cake sale into smaller parts, such as who will bake the cakes and when to hold the cake sale
Taking the problem of baking a cake and thinking about how we can make it the best cake possible
Looking at what different kinds of cake can be made
Which of these would NOT be involved in decomposing a problem?
Thinking about how the problem could be divided into smaller parts
Working out who could help you solve a part of the problem
Adding more parts to the problem so it becomes more complex
Which of these is an example of decomposition?
Guessing who has solved a crime from looking at patterns that have happened before
Solving the complex problem of a crime by breaking it down into when the crime was committed and were there any witnesses
Looking at what different crimes could be committed
What is the purpose of translators in computer programming?
To convert high-level language into low-level language
To increase the execution speed of the program
To reduce the size of the program
To enhance the security of the program
Which of the following is NOT a type of translator?
Assembler
Compiler
Interpreter
Debugger
Which of these is a advantage of using a compiler over an interpreter?
It translates code line by line
It produces executable files
It requires less memory
It optimizes code for readability
Which of the following is a disadvantage of compilers?
They cannot optimize code
They translate source code into object code one instruction at a time
They produce object code that is not executable
They require the source code to be re-compiled for every change
Which of these is an advantage of interpreting code?
Errors can be quickly spotted and corrected
It optimizes code for performance automatically
It produces an executable file
It does not require the source code to be present
Why might interpreted programs run more slowly than compiled programs?
Because they do not require memory for translation
Because they are compiled into object code in one go
Because each instruction is translated as it is executed
Because they are optimized for memory usage
What is source code?
A type of low-level programming language
The original code written by the programmer in a high-level language
The code generated after compilation
Code that is ready to be executed by the computer
What is machine code?
A type of high-level programming language
Code that can be directly executed by the computer's processor
A type of interpreter
A code given to a type of processor
Complete the sentence below:
(a) translate all the (b) source code into (c) in one go to produce an (d) file.
Which of these are NOT true about interpreting?
Interpreting translates and executes each line in turn.
Interpreting produces platform independent programs.
Interpreting is faster than compiling.
Interpreting converts machine code into high-level source code.
Translates all of the source code into machine code in one go
Assembler
Compiler
Interpreter
Compilers... [2 answers]
Create a single executable file
Take a long time to translate
Are useful for debugging
Only translate assembly code
High level languages require a (a) to convert code created by programmers into binary.
Machine code is written in English?
True
False
Yes
19
What will happen if the user's book return is late?
Sends them an SMS (text)
Does not send them an SMS (text)
This flowchart is made to...
Calculate the area and perimeter of a square
Output figures of different sizes
Calculate the area and perimeter of a circle
Find out how long it takes to get to the moon
In this flowchart, r ...
is the radius of a circle
stands for random number
represents a running total
is a miscellaneous variable
In this flowchart the diamond shape helps with...
Deciding whether the student should pass or fail
Adding up the student's marks
Making sure the student gets good marks
Checking the student's general behaviour
This flowchart is made to ...
Check whether a number is odd or even
Decide if we like a number or not
Calculate the remainder of a number + 2
Help people with Maths
What is the purpose of testing?
To find errors in the program
To ensure that a program meets the given requirements
To find ways the program can be broken
Final Testing is testing a program when all the development is complete, what is the other type of testing known as?
Terminal
Iterative
Looping
Continuous
Test Plans and Tables are used to ensure the database is working as it should
True
False
Select the correct types of tests
Normal / Valid
Erroneous / Invalid
Boundary / Extreme
Data Type
A new user is asked to enter their postcode
ME14 5DT would be an example of a valid / normal test
True
False
A student is asked to enter their school year group
9 would be an example of an erroneous test
True
False
Testing sensible, possible data that the program should accept and be able to process
Erroneous / Invalid
Boundary / Extreme
Normal / Valid
Testing valid data that falls at the upper or lower ranges
Erroneous / Invalid
Boundary / Extreme
Normal / Valid
Testing data that the program cannot process and should not accept
Erroneous / Invalid
Boundary / Extreme
Normal / Valid
A user is considered a teenager on the system until their age is 13 or over
13 would be an example of a boundary / extreme test
True
False
Testing data that the program cannot process and should not accept
(a)
Testing valid data that falls at the upper or lower ranges
(a)
Testing sensible, possible data that the program should accept and be able to process
(a)
Test plans and tables allow you to ensure that all information in the database is correct
True
False
In the exam, you will be told which tests to perform and on which fields
True
False
In the exam, you will be given a set of criteria for you to create your own tests for
True
False
A series of detailed tests and their expected outcomes
Test Plan
Test Table
A series of detailed tests, their expected outcomes, their actual outcomes and comments on their success
Test Plan
Test Table
Select all elements of an effective test table
Test Type
Test Data Items
Expected Result
Actual Result
Logo
A test plan and table should be designed for anyone to complete, not necessarily just for you
True
False
You should deliberately engineer tests that fail so that you have more to write about in the exam
True
False
Ideally, how many different tests should you include for each criteria?
1
2
3
Match the following SQL term with a description - FROM
The criteria which must be met
The fields to display
The field and order used to sort the results
The table used in the query
Match the following SQL term with a description - SELECT
The fields to display
The table used in the query
The criteria which must be met
The field and order used to sort the results
Match the following SQL term with a description - WHERE
The table used in the query
The fields to display
The field and order used to sort the results
The criteria which must be set
In what order does SQL process the instructions?
FROM - SELECT - WHERE - ORDER BY
WHERE - FROM - SELECT - ORDER BY
SELECT - FROM - WHERE - ORDER BY
SELECT - FROM - ORDER By - WHERE
Which symbol would you use to represent more than 50
= 50
< 50
> 50
# 50
Which word is missing from the following SQL statement?
Select * table_name
With
Where
From
And
The SQL statement being run is:
SELECT player_name, score FROM leaderboard;
What is the name of the table in this query?
SELECT
player_name
score
leaderboard
Which SQL statement will show the names and weights of all wrestlers lighter than 170?
SELECT name, weight FROM Wrestler WHERE weight >170;
SELECT name, weight FROM Wrestler WHERE weight <= 170;
SELECT name, weight FROM Wrestler WHERE weight <170;
SELECT name, weight FROM Wrestler WHERE weight >=170;
How many records are in this table?
7
6
5
4
How many fields are there in this table?
6
7
9
42
