WorksheetsOCR A Level Computer Science - 2.x.x
Total questions: 138
Worksheet time: 1hrs 14mins
A programming mechanism that binds together code and the data it manipulates, and that keeps both safe from outside interference and misuse.
Polymorphism
Inheritance
Encapsulation
Object-Oriented Programming
Is the process by which one object can acquire the properties of another object.
Polymorphism
Inheritance
Encapsulation
Object-Oriented Programming
A single object can also be referred to as an...
Object
Singular Object
Instance
Singular
A dog might be an instance of the Pet class?
True
False
Characteristics of OOP.. (Tick all)
Data types
Encapsulation
Inheritance
Polymorphism
algorithm
Which paradigm makes use of methods and attributes to encapsulate data in classes.
Declarative
Imperative
Object oriented
Low level
Refer to the shark class. Which of the following is an instance variable?
age
region
sharkAge
Shark
Why is OOP a powerful programming technique?
Because it's fun
Because it's easy to learn
Because it allows for reusability
It isn't
How many classes can be defined in a single program?
As many as you want
Only 1
Only 100
Only 999
Which is not feature of OOP in general definitions?
Modularity
Code reusability
Duplicate/Redundant data
Efficient Code
A computer routine or snippet of code that can be reused in a computer program.
Container
Function
Computer Programming
Pseudocode
A user-defined name of a program element, such as a variable or constant.
Pseudocode
Data Type
Identifier
Container
A way to represent code in a manner that is easier for a wide range of people to understand.
Computer Programming
Pseudocode
Data Type
Identifier
An attribute attached to a value that tells the compiler or interpreter how the data should be used.
Data Type
Pseudocode
Container
Compiled Language
A variable is...
A memory location used to store a value that can change.
A memory location used to store a value that cannot change
A constant is...
A memory location used to store a value that can change.
A memory location used to store a value that cannot change
'Sequence' means...
When lines of code only run if a condition is met. e.g. IF, ELIF, ELSE
When lines of code loop e.g. WHILE, FOR
When lines of code runs one line after the other
'Selection' means...
When lines of code only run if a condition is met. e.g. IF, ELIF, ELSE
When lines of code loop e.g. WHILE, FOR
When lines of code runs one line after the other
'Iteration' means...
When lines of code only run if a condition is met. e.g. IF, ELIF, ELSE
When lines of code loop e.g. WHILE, FOR
When lines of code runs one line after the other
A STRING is...
A TRUE/FALSE or YES/NO value
A word, or number not used in Maths.
A whole number
A number with a decimal point
An INTERGER is...
A TRUE/FALSE or YES/NO value
A word, or number not used in Maths.
A whole number
A number with a decimal point
A FLOAT is...
A TRUE/FALSE or YES/NO value
A word, or number not used in Maths.
A whole number
A number with a decimal point
A BOOLEAN value is...
A TRUE/FALSE or YES/NO value
A word, or number not used in Maths.
A whole number
A number with a decimal point
The data value '4.5' would be a...
STRING
INTERGER
FLOAT
BOOLEAN
The data value 'Steve' would be a...
STRING
INTERGER
FLOAT
BOOLEAN
The data value '250' would be a...
STRING
INTERGER
FLOAT
BOOLEAN
The data value 'TRUE' would be a...
STRING
INTERGER
FLOAT
BOOLEAN
The data value 'Phone Number: 07284 281837' would be a...
STRING
INTERGER
FLOAT
BOOLEAN
'Casting' means...
Converting data types e.g. int(), str()
Removing unwanted data
Creating a new variable
Creating a new constant
file = open("textfile.txt", "r") means...
Open a file called 'textfile' and add to it.
Open a file called 'textfile', empty it and then write to it
Open a file called 'textfile' and read it.
file = open("textfile.txt", "a") means...
Open a file called 'textfile' and add to it.
Open a file called 'textfile', empty it and then write to it
Open a file called 'textfile' and read it.
file = open("textfile.txt", "w") means...
Open a file called 'textfile' and add to it.
Open a file called 'textfile', empty it and then write to it
Open a file called 'textfile' and read it.
SQL statements always use...
WHERE
FROM
SELECT
SELECT
FROM
WHERE
FROM
SELECT
WHERE
SELECT
WHERE
FROM
To create a sub program, we use:
We create a random number (between 1-6) with...
random = [1,2,3,4,5,6]
random1-6:
random.num(6)
random.randint(1,6)
The examples of maintainability below are... (select 3):
Comments in code
Indentation
Appropriate variable names
Abstraction
Changing an input so it works in a program (e.g. turning lowercase into uppercase)
Input Sanitation
Input Validation
Input Creation
Input Testing
Testing an input and ensuring it is in the correct format or range
Input Sanitation
Input Validation
Input Creation
Input Testing
Authentication means...
Checking a user is who they say they are (e.g. username/password)
Helping a piece of code become more readable
Testing a program while it is being created,
A syntax error means...
An error that still allows the code to run, however not as expected.
An error that prevents the code from running as it does not follow the code language rules.
A logic error means...
An error that still allows the code to run, however not as expected.
An error that prevents the code from running as it does not follow the code language rules.
prnit("Welcome to the Game")
is an example of a...
Logic Error
Syntax Error
score = 1
print("score")
is an example of a...
Logic Error
Syntax Error
The purpose of testing in programming is... (select 2):
To check that the program hits the user requirements
To save variables in the correct places in RAM
To add comments into the code
To check the code runs as expected.
Final/terminal testing takes place...
Many times throughout a programming project
At the end of a programming project
Iterative testing takes place...
Many times throughout a programming project
At the end of a programming project
Normal test data is used to...
Test a value that is just inside/outside of what should/shouldn't be accepted.
Test a value that is expected in a program and should work.
Test a value that should be rejected by the program.
Boundary test data is used to...
Test a value that is just inside/outside of what should/shouldn't be accepted.
Test a value that is expected in a program and should work.
Test a value that should be rejected by the program.
Erroneous test data is used to...
Test a value that is just inside/outside of what should/shouldn't be accepted.
Test a value that is expected in a program and should work.
Test a value that should be rejected by the program.
What logic gate is this?
AND
NOT
OR
What logic gate is this?
AND
NOT
OR
What logic gate is this?
AND
NOT
OR
If 1 is the input, the output will be...
0
1
If input A is 1, and input B is 1, the output will be...
0
1
If input A is 1 and input B is 0, the output will be...
0
1
DIV means...
Dividing without including the remainder
Dividing, but only writing the remainder
Multiplying the number by itself
MOD means...
Dividing without including the remainder
Dividing, but only writing the remainder
Multiplying the number by itself
^ means...
Dividing without including the remainder
Dividing, but only writing the remainder
Multiplying the number by itself
13 DIV 4 =
(a)
29 DIV 5 =
(a)
63 DIV 10 =
(a)
34 MOD 5 =
(a)
12 MOD 6 =
(a)
100 MOD 9 =
(a)
4^2 =
(a)
2^3 =
(a)
3^3 =
(a)
High-level language means...
A programming language that uses short and basic single words
A programming language that uses English-like words
1s and 0s - used by the CPU
Low-level language means...
A programming language that uses short and basic single words
A programming language that uses English-like words
1s and 0s - used by the CPU
Machine code means...
A programming language that uses short and basic single words
A programming language that uses English-like words
1s and 0s - used by the CPU
" score = input("Enter a number") "
is an example of...
High-level language
Low-level language
Machine code
INP 10
STA 12
OUT 28
is an example of...
High-level language
Low-level language
Machine code
1001 0101
0011 1111
0101 1110
is an example of...
High-level language
Low-level language
Machine code
A translator...
Tests an input and changes it to fit with the program (e.g. lowercase to uppercase)
Tests the code and checks for errors
Tells the program where the variables are stored in RAM
Converts high-level language into machine code so the CPU can run the program.
A complier translator... (select 2):
... is used during development of code
...is used at the end when the code is finished
...is quick and reports errors as is translates
...takes some time and produces a list of errors at the end
An interpreter translator... (select 2):
... is used during development of code
...is used at the end when the code is finished
...is quick and reports errors as is translates
...takes some time and produces a list of errors at the end
2 examples of IDE tools are...
Editor tools (e.g. line numbering, colour coding)
Selection (when lines of code run one after another)
Iteration (when lines of code loop)
Translators
2 examples of IDE tools are...
Variable names must be suitable and appropriately named.
Run-time environment (You can run the code before its finished)
Debugging tools (errors are reported and advice is given to the user)
Selection (lines of code only runs if a condition is met)
The user can input something using the code...
input("Enter a value")
print("Enter a value")
variable("Enter a value")
while("Enter a value")
We can output something using the code...
input("Hello")
print("Hello")
variable("Hello")
while("Hello")
What is an Algorithm?
A set of instructions that, when executed, completes a defined task that solves a problem.
The process of breaking apart a problem.
The process of removing unnecessary detail.
A sequence of instructions.
How do we represent the complexity of an algorithm?
Big-R
Big-O
Big-N
Big-A
What order of complexity does this graph represent?
Exponential
Polynomial
Linear
Logarithmic
What order of complexity does this graph represent?
Exponential
Polynomial
Linear
Logarithmic
What order of complexity does this graph represent?
Exponential
Polynomial
Linear
Logarithmic
What order of complexity does this graph represent?
Exponential
Polynomial
Linear
Logarithmic
What order of complexity does this graph represent?
Exponential
Polynomial
Linear
Constant
Which of these problems are solved by algorithms?
Routing
Encryption
Sorting
Searching
All of the other four.
What is the time complexity of this algorithm?
O(n)
O(2n)
O(log n)
O(n2)
O(1)
What is the time complexity of this algorithm?
O(n)
O(2n)
O(log n)
O(n2)
O(1)
What is the time complexity of this algorithm?
O(n)
O(2n)
O(log n)
O(n2)
O(1)
What is the time complexity of this algorithm?
O(n)
O(2n)
O(log n)
O(n2)
O(1)
What is the time complexity of this algorithm?
O(n)
O(2n)
O(log n)
O(n2)
O(1)
What is the Big-O Notation of "Divide & Conquer" Algorithms?
O(n)
O(2n)
O(log n)
O(n2)
O(1)
What is the Big-O Notation of a combination lock with 4 digits, each digit having 1 of 10 possible values?
O(n)
O(10n)
O(log n)
O(n2)
O(1)
What is the Big-O Notation of picking a sequence of 10 balls from a bag of 10 different coloured balls (the ball is not put back into the bag after being picked)?
O(n)
O(n!)
O(log n)
O(n2)
O(1)
Which of the following is not done by abstraction?
Identifies essential details
Disregards non-essential information
Breaks the problem down into smaller tasks
Which of the following is not done by decomposition?
Allows multiple people to work on the problem together
Disregards non-essential information
Breaks the problem down into smaller tasks
When drawing a dog, which of the following characteristics is non-essential?
Dogs have 4 paws
Dogs have fur
Dogs have brown fur
When designing a building that must be accessible for wheelchairs, which of the following characteristics is non-essential?
Number of doors
Number of walls
Number of wall paintings
One advantage of abstraction is that it means no mistakes can be made
True
False
You could use abstraction to replace specific objects with simple shapes
True
False
This is a good example of decomposition
Sit down
Do homework
True
False
Decomposition allows each task to become _______
More manageable
Easier
Quicker
Decomposition allows the entire task to be completed as _____
A Team
A Whole
Quickly as possible
Abstraction and Decomposition are separate concepts, you would usually choose to do either one or the other
True
False
It is always necessary to decompose a task
True
False
Abstraction and Decomposition are examples of...
Computational Thinking
Algorithmic Thinking
Computer Science
Logical Reasoning
What is pattern recognition?
Breaking down a complex problem into smaller problems
Looking for similarities among and within problems
Building models from patterns
Why do we need to look for patterns in problems?
Patterns make it easier for us to solve complex problems
We don't need to look for patterns
Patterns make it more difficult complex problems
If you don't look for patterns in a problem, your solution might be _____
Wrong
Inefficient
Too slow
Identifying the steps involved in solving a problem
Abstraction
Decomposition
Pattern Recognition
Algorithmic Thinking
Looking for similarities and trends within a problem
Abstraction
Decomposition
Pattern recognition
Algorithmic Thinking
What is a flowchart?
A visual representation of an algorithm.
A diagram that shows abstraction.
A series of shapes.
A school database has lots of information on students, the data manager needs to use abstraction. What data should she leave out?
Age
Guardian's phone numbers
Classes
Eye colour
Which of the following is not done by abstraction?
Identifies essential details
Disregards non-essential information
Breaks the problem down into smaller tasks
Which of the following is not done by decomposition?
Allows multiple people to work on the problem together
Disregards non-essential information
Breaks the problem down into smaller tasks
When drawing a dog, which of the following characteristics is non-essential?
Dogs have 4 paws
Dogs have fur
Dogs can have brown fur
You could use abstraction to replace specific objects with simple shapes
True
False
Why do we need to look for patterns in problems?
Patterns make it easier for us to solve complex problems
We don't need to look for patterns
Patterns make it more difficult complex problems
What does the circle symbol mean in a state transition diagram?
start state
state
transition
end state
What are the three types of errors in programming?
runtime, syntax, logic
logic, spelling, operator
spelling, logic, runtime
syntax, operator, logic
What does erroneous data mean?
Data that is right on the edge of being right and wrong
Data that you expect the user to enter
Data that you do not expect the user to enter
What is a finite state machine?
A machine that can do one thing
Pseudo code that represents an algorithm
A machine that has a finite amount of things to do
A representation of how something changes from one state to another
What is functional abstraction?
Taking out bits of irrelevant detail out of a function
Using a function, but how it works is on no interest to the user
Using a function within your program
What type of diagram is this?
Entity relationship diagram
Flow chart
State transition diagram
Class diagram
Which string would be accepted?
abba
bbac
abac
caaba
Which is an example of iteration?
print("Hello")
if a == b:
for I in range (1,10):
This piece of code uses ...
Sequence
Selection
Iteration
What type of diagram is the image of?
State diagram
Entity relationship diagram
Hierarchy chart
Flow chart
What sorting algorithm is shown here?
Bubble sort
Merge sort
Quick sort
Insertion sort
