Paper 2 Revision Slides
Paper 2 Revision Slides
1 Computational Thinking:
Create, Complete and Refine Algorithms using Identifying common errors
Computational thinking is approaching Flowcharts or Pseudocode.
problems in a way that both human and Be clear what is meant by a syntax error and a
Tips: logic error…
computer can solve, an algorithmic approach • If you are given a structure already, use the
using: format of it to respond with (e.g. if provided Syntax – incorrect spelling, grammar or
Abstraction – The process of removing with a flowchart, continue with it!) indentation.
unnecessary details to focus on those that • Ensure you are using variables and input Logic – program runs but not as expected as
matter to solve the problem. assignments correctly, all inputs will want a there may be incorrect declarations, variables
variable attaching being reset or similar.
Decomposition – The process of breaking a • E.g. A = input(“Enter something here”)
larger problem down into more manageable • You do get marked for the messages used so Trace Tables:
steps. check the question. These can be the trickiest topic but ensure
Algorithmic Thinking – Trying to construct • For any repeating code – any iteration will get a you do the following:
problems into step by step approaches that mark even if it is while True:… most will want a
while loop condition so ensure you know the • Read the question/code provided
both human and computers can solve.
correct way to display not equal to != as well as • Look out for lengths being checked and if
Identifying Inputs, Processes and Outputs for comparison == they are using equal to or just less than
a problem – context driven questions so read • For any flowchart, ensure only one start/end!
the question and materials provided. As well as all lines with arrows and decision • Pay special attention to the loop being
with y/n! used and the impact it has
Structure Diagrams – • Trace the variable throughout – you can
a method of laying out write all over the question!
a program for navigation
purposes, often for
menu based programs.
2.1 Sort/Searching Algorithms:
Searching: Sorting: Searching:
Linear Search goes through the data items Bubble Sort - this compares adjacent items and Merge Sort - splits the data down until
from start to finish, in order, until it either swaps them accordingly they are individual values, this then re-
finds the item it is looking for or reaches the builds them as groups of 2, then 4 etc. until
end of the list. It has two loops: the list is rebuilt.
It is important to mention order for this as well An inner loop that compares adjacent items and
as being clear about the starting and end determines if they need to be swapped (which is
point. done with use of a temporary holding variable)
Binary Searches need the data to be sorted in An outer loop that continues until there have been
order before it is able to search. no swaps performed in a pass of the data to stop
the process.
Binary Search will find a mid-point of the data
and compare this against the item being
searched for, if it is a match – it stops and How they handle data sets:
returns this value. Insertion is best with large data sets, merge
Insertion Sort:
Otherwise it will discard the half of the list is as well.
that does not contain this value (higher or Begins by using the first value as the comparison
until it runs into a larger value – this becomes the With small data sets they perform similarly,
lower) as well as the middle point. however, merge does take a set amount of
new comparison point. Smaller values are
It will then select a new middle point and compared to each value lower than the steps which can make it slower than the
begin the process again comparison point until it finds the correct place in others.
This repeats until either the value is found or the list
there is one remaining value that isn’t the
value being searched for.
2.2 Programming Fundamentals
Inputs/Outputs are done using the input and Operators: Data Types:
print statements and enable the user to
interact and receive feedback. You are expected to know and use the following: Integer – whole number without decimals
e.g. 8
Variables are temporary stores of data
Real (Or Float) – numbers that includes
Constants should be values that do not change decimal points e.g. 7.5
such as the value of Pi
Boolean – A true or false style question
Assigning a variable is done by Variable = Value with only two possibilities
Sequence is the order that code is carried out Character – any individual letter, number or
in, follows line by line – selection and iteration symbol
statements impact sequence.
String – a group of letters, numbers and/or
Selection is where a program makes a symbols
decision, IF, ELIF and ELSE statements are DIV is integer division meaning that any decimal
where they are found in code. Processes related to Data Types:
places are removed.
Iteration is a name for loops or repeated code, Casting – The process of converting the
MOD shows the remainder of a integer division, type of a variable from one to another
there are two types you may encounter: e.g. 76 MOD 3 would show 1.
Count based: This is done by for I in range(x): Concatenation – The joining of two strings
You should also be clear between equal to and not together via the + sign
where I increases by 1 each iteration and x is equal to as these are guaranteed to be needed
the number of times it will run in total. and you will lose marks for not using correct
Condition Based: This is the while loops that symbols or using a single equals sign for
will only run until the condition has been met, comparisons!
e.g. while lives > 0 will continue until the lives
variable exceeds 0.
2.2.3 Additional Programming Techniques
String Manipulation Methods: Use of Records Arrays
Length = len(string) Records is a term for data that is stored within a Arrays are essentially lists in Python, to
database, each field has a separate data type access an item in an array it has a specific
This provides the length of a string, characters attached, e.g. name as string index that begins at 0 e.g.
include space.
These are accessed by using SQL code to retrieve Names = [“Bob”,”Steve”,”Will”,”Dave”]
Substring = substring(x, y) the data needed.
Print(Names[0])
Where x is the from character and y being the SQL
to character. Would print Bob
For any SQL question you need the following
Converting between cases These can also be two dimensional where
SELECT – generally you will use the wildcard there is an x and y to navigate, for these
X.lower() or X.upper() symbol * , however you can also list individual questions just read the example given as
fields you want, e.g. SELECT name, dob, address they will tell you how to navigate it with an
for example. example, e.g. George is at [0][1]
File Handling:
FROM – is always the table that is listed in the odd Functions
For any file handling question – you need to do font in the question
all 4 steps in order to achieve the marks. To declare a function you will start with the
WHERE – read the question as this tends to be word def and then any parameters
Open is done by filename = open(“file.txt”,”r”) writing a conditional statement e.g. where value > (variables needed) pulled in the brackets
Read = filename.readline() 5 or subject == “Art” after