0% found this document useful (0 votes)
23 views7 pages

Paper 2 Revision Slides

Uploaded by

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

Paper 2 Revision Slides

Uploaded by

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

2.

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

Write = filename.write(content_to_write) Random Number Generations - two methods: E.g.

Close = filename.close() x = random.randint(1,6) or Def triangle(sides, length)


Dice = [1,2,3,4,5,6] To call a function, you just name it and
include parameters e.g. triangle(3,10)
X = random.choice(Dice)
2.3 Producing Robust Programs
Defensive Design Considerations Maintainability Testing:
Anticipating Misuse – Humans are the biggest A bit part of the maintainability questions is to Purpose of Testing – to check that the
weak point of most IT systems and therefore look at the example given as there often is one or program works as expected and that there
you have to consider how to prevent more methods that are not applicable to it – for are no errors. Examples in the test are fine.
accidental as well as unintentional misuse. example indenting code that doesn’t need it or
Examples include checking: variable names where they are already sensibly Iterative Testing – done during the
named. development of the program.
Length check – that data is between a
specified number of characters Comments are the safest bet, subroutines is often Final/Terminal Testing – done at the end of
a good idea but again do check to see if this has development.
Type check – that the data type matches been completed already Syntax Errors – incorrect spelling or
Range check – that the value is between a set For each of these methods explain how it helps – grammar errors.
range of values, e.g. dates for DoB see below Logic Errors – when the program still runs
Format check – that the layout is expected, Comments – allows the programmer to give but does not work as expected
e.g. UK date over American (dd/mm/yy) specific guidance about the codes functionality Test data – in the exam when you are
Presence check – use of captcha/2 factor Indentation – makes the code more readable and providing test data, be specific rather than
authentication. helps the program flow better giving descriptions!
Divide by zero – ensure that the users cannot Subroutine – reduces the amount of overall code Normal – as expected and will work.
do this needed and therefore is more efficient to debug Boundary – the high/low values that will
Authentication – is checking that a user is Sensible Variable Names – makes it clear to the still work but are at each end of the
verified/checked by the computer in some user what the intention of each variable is spectrum.
manner to access the materials.
Erroneous – incorrect data that will not
Validation – that data is acceptable e.g. a valid work and produce an error
date – it doesn’t have to be accurate.
2.4 Boolean Logic
Boolean Logic Logic Gates: Tackling combined logic gates:
AND is where two conditions must be met in It is important for you to draw the symbol You will be often asked to draw larger
order to return a true or 1 value correctly – you will be marked for this, writing the circuits but generally of 3 or so gates.
name on a poor drawing is not accepted.
OR is where one or both conditions must be It is worthwhile to show your working out
met in order to return a true or 1 value where possible by adding additional
columns to work out the result from an
NOT is an inverter which means it does the initial calculation
opposite so a 0 value would be changed to 1
E.g. you may use columns to record the
Truth tables show the possibilities of all inputs value of C, D and E to make follow up parts
and outputs – it is vital to use both the word easier and to avoid error.
highlighted words in the exam to show
dependency.
C D
You will be expected to use Boolean logic
during pseudocode tasks
It is important that for any comparison that Note the circle on the end of the NOT gate! E
involves Boolean logic that you include the You are expected to be able to use and combine
condition on BOTH sides of the AND/OR the following truth tables
e.g. C would record the answer to NOT A
If name == “” or surname == “” D would record the answer to C AND E
Is acceptable E would record the answer to A or B
If name or surname == “” Number of possibly combinations is 2 ^
Is not acceptable number of inputs, e.g. 3 inputs – 2^3 = 8
2.5 Languages and Integrated Development Environments
Characteristics of Languages – High and low Compiler vs Interpreter IDEs (you need to know 3-4):
level languages are used to describe
programming constructs that are translated Compilers: Debugging tools for finding logic errors:
back into binary code for the CPU to use. • Translate the code all at once
• Won’t compile if an error is present Breakpoints to stop a program during
High Level languages refer to coding languages • Produce a separate executable file execution when an error is found.
that are more similar in nature to English e.g. • This file can be run without the compiler Stepping through lines of code one at a
Python or Java • Faster than an interpreter as code is compiled time to check which lines are executing.
and therefore doesn’t need to be re-translated
Low Level languages refer to languages with Help with preventing and identifying
more simplistic layout or one closer to binary syntax errors:
code such as Assembly Code which uses Interpreter:
simple mnemonics such as inp and out or • Translate the code line by one Illustrating keyword syntax and auto-
Machine Code which is binary values. • Will keep running until it stops or an error is completing command entry.
found Error highlighting.
Why are translators needed? • Relies on the interpreter being present to run
Computers can only use binary code and need as well as the source code Run-time environment:
anything that is not in this format to be Output window.
translated by either an interpreter or compiler.
Simulating the different devices that the
See blue column. program can run on.
Usability functions:
Navigation, showing/hiding sections of
code.
Commenting or indenting regions of code.

You might also like