2024 Computer Science OCR J277 GCSE Complete Paper 2 Revision Lesson (1) - en-GB
2024 Computer Science OCR J277 GCSE Complete Paper 2 Revision Lesson (1) - en-GB
0:11
This is my updated 2023 Paper 2 OCRJ 277 revision lesson.
0:19
Don't know why I'm telling you all that.
0:21
It is there just in front of you on the title screen there.
0:24
This will be very similar to the previous revision video I've done for paper two.
0:28
It's just a little bit tweaked and I've got a few extra slides here and there just to give a bit
more detail based on some feedback I had from the previous video.
0:38
So for each section, I will start with the actual specification from OCR and that way you
can see exactly what you need to be revising, what is required, what is not required for
that topic.
0:51
So we're going to start with the beginning of Paper 2 and that is 2 point 1.1,
computational thinking.
0:59
So computational thinking is all about structuring solutions to problems in a way that
computers can easily follow, and that is our decomposition, our abstraction, our pattern
recognition, and our algorithms.
1:13
Decomposition is breaking a problem down into smaller sub problems.
1:18
Once each sub problem is small and simple enough it can be tackled individually.
1:23
Abstraction is removing or hiding unnecessary details from a problem so that the
important details can be focused on or be more easily understood.
1:35
Pattern recognition is looking for similarities among and within problems, and algorithmic
thinking is deciding on the order that instructions are carried out and identifying
decisions that need to be made by the computer.
1:47
So for each of these, please memorise the definition.
1:51
With my current GCSE students, they keep complaining that every single paper I give
them, they're asked to define abstraction, and I have to keep telling them.
2:00
I will stop giving you questions on abstraction when every single student gets the
definition correct.
2:06
Moving on, we are at 21.2 designing, creating and refining algorithms.
2:14
So first of all identifying the inputs, processes and outputs for a problem.
2:18
Remember, computer systems accept input from a user or sensors or loaded from a data
file.
2:24
They process that data.
2:26
They output the results back to the user in some format.
2:30
Programmers write programmes to process inputs in order to provide the needed output.
2:35
The situation is always input, process output.
2:41
A structure diagram is a graphical method of decomposing a problem with each layer,
breaking down the layer above it into smaller and smaller sub problems.
2:51
So you may be asked to create a structure diagram in the exam.
2:56
So here we have the S1 Peri online merchandising system.
3:00
I've broken it down into a user login, a search function, a sales function, and a reorder
function.
3:06
And sales has been further divided into a shopping basket and payment sections.
3:12
Flow chart, sometimes called flow diagram.
3:15
This is a graphical representation of an algorithm and uses symbols to denote each step,
with arrows showing how to move between each step.
3:24
We've got the following symbols, and you do need to learn these guys.
3:28
If you're doing a flow chart, you can't get the shapes wrong.
3:32
You've got to get your line, your process, your subroutine, your input, your output, your
decision and your terminal symbols correct.
3:40
So here we have a simple flow chart representing a programme that repeatedly asks for
a number and adds this to the total.
3:46
When the user selects not to continue, the total is printed.
3:50
So we start with the terminal symbol.
3:53
To start, we have a process which is the total is equal to 0.
3:57
We've got some input with the parallelogram symbol where we enter a number, a
process where we add the total and the number together, store it back as total.
4:06
We now have a decision.
4:07
Do we enter more numbers?
4:09
Yes.
4:09
Go back to enter number?
4:11
No.
4:11
We output total and then we end the programme.
4:14
In this case, not too difficult, you just have to decompose the problem, get the correct
symbols in, get the correct sequence, making sure a decision is correct and you've got
the inputs and outputs as required.
4:26
Pseudocode is a textual representation of an algorithm.
4:31
It is very closely related to high level languages, although it does not require the same
precise syntax.
4:39
With pseudocode, there's no such thing as correct pseudocode.
4:43
It's all part of the planning stage.
4:45
It enables programmers to communicate algorithms to other programmers without
worrying exactly which language they know.
4:53
So here we've got a very simple example of pseudocode.
4:56
This algorithm finds whether a positive number is odd or even through repeated
subtraction.
5:02
Even though the syntax is quite loose with pseudocode, you still need to use the coding
keywords and structure it like a programme.
5:10
So we've got the input, we've got the while, we've got the if, the L, if, we've got all that
sort of stuff.
5:16
It looks kind of like computer code, it's just a bit simplified.
5:21
Similar to pseudocode but different.
5:24
Is the OCR reference language for the J277 exam syllabus.
5:29
In Paper two-part B, you'll be asked to answer coding questions in either the OCR
reference language or a high level language that you've studied.
5:39
The OCR reference language is a strictly formalised version of pseudocode.
5:45
You have to follow the syntax precisely or you will lose marks.
5:49
So it's not like pseudo code where you can kind of make it up as you go along.
5:53
As long as it makes sense, you'll be OK.
5:55
OCIO reference language.
5:57
If you want to use this in paper two-part B, you need to download the exam syllabus, you
need to look at the spec and you need to practise.
6:05
OCIO reference language.
6:07
When it speaks about high level, it includes a whole family of different languages like
Python, C, CC, Java, JavaScript, Visual Basic, PHP, Delphi or Basic.
6:19
Essentially whichever one you're most familiar with from your studies.
6:23
And I think for most of you that will probably be Python trace tables and identifying
common errors.
6:29
When an algorithm has been defined, it needs to be checked for correctness.
6:34
For this we can use a trace table, a tool that can be used to follow each line of an
algorithm through step by step.
6:41
The trace table will show the contents of each variable after each line has been carried
out and will also show any output from the programme.
6:49
So here we've got a very simple programme.
6:50
It's just 4 lines of code.
6:52
And here is the trace table showing you what happens when we run the programme.
6:56
We start with the line number column.
6:58
Notice that doesn't necessarily operate in sequence.
7:01
We have 4 lines of code, but it goes 1234234234, etcetera.
7:07
Line one only executes once and then we're in a loop, so it keeps repeating 2-3 and four
until we exit the loop.
7:15
After the line, we have the next column which is one of the variables.
7:18
It's the only variable in this programme which is number, and we have to record how that
value changes as the programme is run.
7:25
The next column is.
7:26
We evaluate the condition is the number less than 11 true or false?
7:31
And in the final column we have any output.
7:34
So obviously the output is only when you see the print statement in the programme.
7:38
It's not every line, it's not when we change the value of number.
7:42
So you go through the programme line by line, you complete the table double checking
it.
7:46
Don't do it too quickly.
7:48
This is a much bigger part of the exam than it used to be, so you're almost certainly
going to have some trace table to fill in in paper too.
7:55
Sometimes you're going to have to use this to identify an error in a programme, and in
fact any time you've got to identify an error, you probably want to do a quick trace table.
8:04
If you know that there is an error, pay attention to it specifically and you'll see
somewhere one of the variables has been updated or the output of the condition isn't
what you'd expect and that kind of helps you to track down what the error is.
8:17
When you are completing the trace tables, Please remember in the exam they will give
you the exact number of columns and rows required.
8:25
If you think you need less or more than they've given you, you have made a mistake.
8:29
Go back double check.
8:32
The next section is 2 point 1.3 searching and sorting algorithms.
8:37
So starting with standard searching algorithms, we will begin with a linear search.
8:43
A linear search is carried out by inspecting each item of the list in turn to check if it's the
desired value.
8:51
If it matches, you have found the item.
8:53
Otherwise, the next item in the list must be checked.
8:56
If the algorithm gets to the end of the list without finding the item, then it is not in the
list.
9:02
The linear search is relatively inefficient, but works on any list even if the data is not
sorted.
9:09
It is also very easy to code.
9:11
Every single item in the list must be checked before you can be certain that the item
required is not in the list.
9:19
So here we have an algorithm for the linear search.
9:22
You don't need to be able to reproduce this in the exam.
9:26
However, you have to be familiar with this because you may be given some code or
some pseudocode or an algorithm, and you'll have to recognise what type of searching or
sorting algorithm they've given you.
9:38
So take a moment and think about this.
9:40
I'm not going to spend too much time on it, but you do have to be familiar with how it
looks in pseudocode.
9:48
So let's have a worked example.
9:49
We need to find the item 9 in this list using a linear search.
9:54
That's really simple.
9:56
We look at the first item in the list and we compare it to the item we're looking for.
10:00
First item is 7/7 is not equal to 9.
10:03
We move along one.
10:04
The next item in the list, well, we have two.
10:07
Is 2 equal to 9?
10:08
No move along to the next item in the list.
10:10
9 is equal to 9.
10:12
We found a match we can stop checking.
10:16
The next one we need to know is binary search, and this is a much more efficient
algorithm to find a value in a list.
10:22
However, with a binary search, the list must be in order.
10:27
We start by looking at the middle value in a sorted list.
10:31
If there are an even number of values and there isn't an exact middle, generally the
value to the left of the middle is chosen.
10:39
You kind of round down, so to speak.
10:43
You can also round up and move to the right if you wanted to.
10:46
It doesn't really make a difference as long as you're consistent with each step.
10:50
Either you're always moving to the left or you're always moving to the right.
10:53
If there isn't an exact middle, there is an exact middle.
10:57
That's the one you want to go for.
10:58
If the middle value is the one you are searching for, then the algorithm finishes.
11:03
However, if it is not, you discard the bottom half of the list if the middle value is smaller
than the one we're searching for, or discard the top half of the list if the middle number is
larger.
11:17
Either way, we also discard the middle value each time.
11:22
You then repeat the process by choosing the middle value of the remaining items and
comparing this to the value required.
11:29
If you get to a situation where the list only has one item and is not the one we're
searching for, then the value is not in the list.
11:38
A binary search is very efficient.
11:40
You could find a specific value in a list of 1,000,000 numbers in a maximum of 21
comparisons, but it will only work on a sorted list.
11:49
And obviously it's a bit more difficult to programme again.
11:52
Here we have the algorithm for you to have a look at.
11:55
Again, you don't need to reproduce this or programme in the exam.
11:58
You just have to be able to see this and go aha, I recognise what this is.
12:03
So here we go.
12:04
We start with an ordered list of numbers and maybe we have to find a certain value, in
this case 2.
12:11
So what I always like to do is start by putting down the low point and the midpoint and
the high point.
12:16
Midpoint in this case is quite easy because if it's clearly the value 4 here in the list, 3
values to either side, it's going to be the midpoint, the mid value.
12:27
So we compare whatever element, whatever value is stored at the midpoint to the value
we're looking for.
12:33
2 is not equal to four, two is less than four.
12:38
Therefore, we discard the midpoint and the entire top half of the list and only look at the
bottom half of the list for the next step.
12:47
And that leaves us with 1-2 and three again, low point midpoint.
12:52
High point midpoint's nice and easy to find.
12:54
Notice that the value 4 is no longer in the list because we've discarded the midpoint.
12:59
We know it's not the number we're looking for, so we don't include it after the discarding.
13:04
And that is a common mistake that I notice a lot of students make.
13:08
O we have this list 1-2 and three.
13:10
Again, the midpoint is what we look at first we compare 2:00 to 2:00.
13:14
Well 2 is equal to 2.
13:16
So we have a match and we can stop checking now.
13:20
I found from marking previous exams from my students.
13:23
I just don't get enough detail with this.
13:25
Make sure you show each step.
13:28
What is the middle value?
13:30
What are you comparing the middle value to?
13:33
You have to use the actual data, the actual values from the list.
13:36
You can't just write out the steps generically.
13:39
You're not going to get full credit.
13:41
Use the values, show the comparisons, show what you're discarding, show the next
repeated steps.
13:48
Make sure you do get all the marks here by giving enough detail.
13:53
Next we have sorting algorithms and we'll start with a bubble sort and this works by
comparing pairs of values.
14:01
If the two values are in the wrong order, they're swapped over.
14:05
This is then repeated for each further pair of values.
14:09
When the last pair of values has been compared, the first pass of the bubble sort
algorithm is complete.
14:16
The algorithm will repeat until a pass has been completed, with no swaps occurring.
14:22
Once this happens, the list is guaranteed to be in order.
14:26
So again, here's a look at the algorithm.
14:28
Just familiarise yourself with that a little bit so you can recognise it in a test.
14:33
So let's do a worked example to sort this list in ascending order.
14:38
Compare 6 and one.
14:40
They're in the wrong order, so they're swapped over.
14:43
The list is now 1694.
14:46
Now 6 and 9 are compared.
14:49
They're in the correct order, no swap needed.
14:52
Next nine and four are compared, they're in the wrong order, so they're swapped over.
14:58
If you're writing this out in a test, make sure you draw some arrows.
15:01
Show what numbers you're swapping, show the lines as you go through it.
15:06
Make it clear you know what you're doing, so you get all the marks.
15:10
So now we've completed the first pass.
15:13
Since at least one swap has taken place, we need to repeat the algorithm.
15:17
One and six are compared.
15:19
Now they're in the correct order, so no swap is needed.
15:23
Six and four are compared.
15:25
They're obviously in the wrong order, so they're swapped over.
15:28
Six and nine are compared.
15:29
They're in the correct order, so no swap is needed.
15:32
So we have 1469, even though we can look at angle.
15:36
Well, that is in the right order, because we've had one swap take place previously.
15:42
The algorithm must go through the whole set of steps again, comparing all the values.
15:48
After this final pass, since no swaps have been carried out, the algorithm is complete and
the values must be in the correct order.
15:56
The insertion sort algorithm splits the list to be sorted into two parts, a sorted side and
an unsorted side.
16:04
Initially, the sorted side contains just the first item in the list, with everything else on the
unsorted side.
16:12
Unlike a bubble sort, an insertion sort does not require multiple passes to check that the
values are in order.
16:18
Once each value has been inserted into the sorted list and the unsorted list is empty, the
list as a whole will be in order.
16:26
Insertion sort is much more efficient than a bubble sort algorithm, but can be relatively
tricky to implement in a high level language.
16:35
Moving values around without overwriting other values can be difficult for inexperienced
programmers.
16:41
So again, we've got the pseudocode here and you can see this is very, very simple.
16:46
However, actually coding this would be quite complicated, so a worked example to sort
into ascending order.
16:53
So you can see we've divided it into a sorted and unsorted section.
16:57
The sorted list just contains the first item which is 619, and four are in the unsorted
section.
17:03
So we take the first item from the unsorted section and we insert it in the right place in
the sorted list.
17:09
Obviously one comes before 6 and we repeat this for the next item.
17:14
So we make sure the 9 is inserted after the six.
17:17
Now 4 is taken and placed into the correct order in the sorted list.
17:22
Now all the numbers are in the sorted list, the unsorted list is empty, all the numbers
have been inserted and the list can be said to be in order.
17:30
The merge sort uses what we call a divide and conquer approach to split data into
individual lists and then merge them all back together in the correct order.
17:41
The way that the lists are merged back together is key to understanding how this
algorithm works.
17:46
The merge sort is much more efficient than either a bubble or insertion.
17:51
It will take a large list of random values and sort them in a very quick amount of time.
17:57
However, a merge sort may not be the best sorting method for nearly sorted or small
lists.
18:03
So again, here's have a little look at the algorithm and then I'll take you through a
worked example.
18:08
So again, we're going to sort this in ascending order.
18:11
First.
18:11
In the divide stage, the original list is split into two sub lists, so we have 6-1 and nine 4.
18:18
Then each of these is now split into two sublists so that each contains only a single
element.
18:25
So if you're writing this out, please show these steps just to make sure you get full credit
that each pair of lists are merged together.
18:33
In the conquer stage, where there are an uneven number of lists, the odd list will simply
remain unmerged until the next step in the process.
18:43
So 6 and one are compared with one being inserted into the new list before the six.
18:48
In the same way the four is inserted before the 9 in the next merged list.
18:55
The merging process is then repeated to merge the pairs of lists together.
18:59
One and four are compared to decide which values will be first with the one being
inserted.
19:05
Six and four are then compared with the four being inserted.
19:08
6 and 9 are then compared with the six being inserted before the 9 is finally inserted and
now the list is in order.
19:15
2.2 point one.
19:17
Programming Fundamentals A variable is a name or a label which is used to identify a
memory location used to store a value that can change while the programme is running.
19:31
A constant is a name or a label which is used to identify a memory location used to store
a value that cannot change while the programme is running.
19:41
Please memorise these definitions.
19:44
These are the kind of questions that come up time and time again, and you can either
get them right or get them wrong all right.
19:50
It's difficult to work it out on the day.
19:52
Just memorise definitions.
19:54
Both are obviously assigned in the same way using the equal symbol.
19:57
So for example, age equals 12, and then we've got an example for a constant.
20:02
Constant Π = 3.14.
20:05
Typically constants.
20:07
You'll have that sort of const at the start in the exam to make sure you can identify that
it's a constant.
20:13
And typically for naming conventions, the name is capitalised, but it doesn't have to be.
20:20
Obviously, we need to put input data into our programme.
20:23
So we can do that by just using a simple input command like you can see here, number
equals input, enter number, and then we can output whatever that value is, for example.
20:33
Now let's move on to look at the three basic programming constructs that we can use to
control the flow of a programme.
20:40
The three that we need to know about are sequence, selection and iteration.
20:45
Students often make mistakes with this.
20:47
They get some code in a question, they're asked to identify which of the fundamental
programming constructs are being used, and we get all kinds of crazy answers.
20:56
You're only going to be using sequence selection and iteration depending on the code
sequence is nice and easy.
21:02
It's the execution of statements one after the other in order.
21:06
Typically programmes run from top to bottom.
21:09
So in the example code here, whether you're in OCR reference language or Python, line 1
executes, then line 2, then line 3, then line four, and then reaches the end the
programme and the programme finishes.
21:19
So it's just sequence.
21:22
Next up we have selection.
21:24
This is the construct used to make decisions in a programme based on the result of a
boolean condition.
21:30
There are two different versions.
21:32
We've got if, else if or the switch case.
21:37
If else.
21:38
If is the version most people are familiar with, and whether you're using an OCR
reference language or Python, it's fairly similar, although there are a few syntactic
differences.
21:48
The main point here is only one of the conditions in the sequence will execute.
21:53
Either it's going to be the if or the else.
21:55
If or the else can't execute to a more, it's only one that can execute.
22:01
Switch case is a little bit more unusual.
22:03
Sometimes it confuses students, but it's very, very similar to if, else if.
22:08
And in fact, you can take a switch case block of code and turn it into if else if very easily.
22:14
So you look at the example here.
22:15
I could set this up to be if name equals Bob, print hi Bob, else if name equals Tom, print,
howdy Tom, else print.
22:25
I don't know you and it will work exactly the same.
22:29
So why do we have this switch case?
22:31
Well, some people think it can be more readable and there's certain types of code where
maybe it will work a bit better than if else if.
22:40
But really, you never have to use switch case.
22:42
You can always use if else if.
22:45
But in the exam you might see some code written in switch case and you just have to be
able to understand it.
22:51
Iteration is the construct used for repeating sections of code sometimes.
22:56
Informally we refer to this as looping.
22:58
We can have count controlled iteration where the code repeats a defined number of
times.
23:04
This is with a for loop, or we could have condition controlled iteration.
23:09
This cheques the condition each time around the loop and decides whether to repeat the
code again or continue with the rest of the programme.
23:16
This can use while or do until.
23:20
Here we've got a couple of examples in both OCR reference language and in Python of
count controlled iteration using for loops.
23:27
The first set of examples will print one to 10 and the second set of examples will print
1357 and 9:00.
23:35
If we start with the OCL reference language version.
23:38
Nice and simple.
23:39
4 count equals one to 10 print count next count.
23:43
The start condition is 1, the end condition is 10 and these are both inclusive.
23:48
Both numbers are included, so 1210 both inclusive.
23:52
Python can be slightly more complicated.
23:56
We use 4 count in range 111.
23:59
The start condition is inclusive, so it starts at 1:00, but the end condition is exclusive.
24:05
It's one more than we need.
24:07
This will run from 1:00 to 10:00 and it will not include 11.
24:11
The second set of examples uses stepping so that we can go 13579 by using steps of
two.
24:19
In the OCR reference language, we just say 4 count equals one to 10, and then we add
Step 2 to the end.
24:25
In Python we add a third number, so it's 4 count in range 111 two.
24:31
The one is the start condition inclusive, the second number is the N condition which is
exclusive, and the third number is the steps, so steps of 213579.
24:42
And finally here we have condition control iteration.
24:46
We have the while which is the most commonly used version and we have that in the
OSIO reference language and in Python.
24:54
That will keep continue to repeat until somebody says something other than yes.
24:58
If they put anything else it will stop and continue with the rest of the programme.
25:03
While is an example of a pre-check condition.
25:06
If the condition is false it might never run.
25:10
So if continue is set to NO in both cases of the while loop, it will just skip over the while
loop and continue with the rest of the programme.
25:17
The do until is perhaps a little bit more interesting in that it's an example of a post check.
25:23
It will always run at least once before it evaluates that condition do until doesn't exist In
Python.
25:30
There isn't really an equivalent structure, but you might see it in the exam, although you
would never have to use it.
25:37
Next up we have common arithmetic operators.
25:40
These are used to carry out basic mathematical operations on numerical values.
25:45
Most of these are quite self-explanatory.
25:49
The more interesting ones are towards the bottom, where we have modulus, floor
division, and exponent.
25:55
Modulus, which is the percentage sign in Python, divides 2 numbers and returns the
remainder.
26:02
So 10 mod 4 is 2 because 10 / 4 is 2 with two leftover, there's a remainder of two floor
division division or the double slash in Python returns the whole number after division,
getting rid of that fraction.
26:23
So 10 Division 3 = 3.
26:26
Because 10 / 3 is 3.33333, we get rid of the fractional part and we're left with the three,
The exponent, which is the little hat symbol in the OCR reference language, or two stars
in Python.
26:39
That is one number to the power of another number.
26:42
So 2 exponent 4 is 16.
26:45
It's 2 to the power 4.
26:48
Comparison operators are used to evaluate expressions to a boolean true or false
condition.
26:54
Again, it's another one of these things you just have to make sure you get right.
26:57
Is it less than?
26:58
Is it greater than?
26:59
Is it less than equal?
27:00
Is it greater than equal To?
27:02
Make sure you know a way of remembering what these are, because it's very important
to get those right in the exam.
27:07
Boolean operators allow multiple conditions to be evaluated.
27:10
You've got your and your OR and your not and.
27:14
Both conditions must be true, or one condition can be true, or the other condition, or
both and not just simply reverse as the condition true becomes false, false becomes true.
27:26
2.2 point two data types.
27:30
Integers are whole numbers, either positive or negative, that have no fractional part.
27:36
So 8 -, 17, et cetera.
27:40
Real numbers, sometimes called floats for example in Python, are used for positive or
negative numbers that can or may have a decimal fraction.
27:51
That language is very important, please use it.
27:54
An example would be -8.5 or 17.0 are examples of real numbers.
28:00
They have these decimal fractions.
28:03
Boolean variables are only used to store true or false.
28:07
A character is a single item from a character set that could be a letter or a character or
even a number, but it has to be in quotation marks.
28:16
And a string is a data type that stores a collection of characters that can be made-up of
letters, numbers, or symbols.
28:24
Again, string should always be in quotation marks.
28:28
Casting is the conversion of one data type to another and there are various methods we
can use to do that.
28:34
We can convert to string, to integer, to real to boolean depending on the situation.
28:40
We usually cast because we want to join strings together, concatenate them before
printing, or we want to do math with numbers that have been input to a programme.
28:51
And generally when we input data to a programme it starts off as a string, so if we want
to do math with it, we need to cast it into an integer or a reel.
28:59
2.2 point three additional programming techniques.
29:04
Quite a lot to get through here, so we're going to start with the use of basic string
manipulation.
29:09
I'm going to use basic in quotation marks because there's quite a lot of string
manipulation you might be asked to do.
29:15
String manipulation tools allow strings to be sliced, concatenated, or modified.
29:20
Slicing is when we extract or slice individual characters or sequences of characters from
a string.
29:27
And concatenation, as I explained previously, just means joining strings together.
29:33
Let's have a look at all the string manipulation code you might be asked to do.
29:37
We're going to start with some text.
29:39
Go to Phrase Computer Science.
29:42
Remember, a string is just an array of characters, and you can see that here we have a
total of 16 characters from zero to 15.
29:51
The first C there is position 0.
29:53
The last E is position 15.
29:55
Please note that in the middle, the 8 is a space.
29:59
Space is a value.
30:02
It has to be stored in your array of characters, here in your string.
30:06
So the space has a position, it has a value.
30:08
It's not nothing.
30:10
It does have a representation for the computer.
30:13
So the first command we're going to look at is how to get the length of some text of a
string in the OCR that's dot length, for example, phrase dot length.
30:23
Whereas in Python we use the Len function.
30:25
We say Len and then phrase in brackets and that will return 16 because there are 16
characters from zero to 15 in my string phrase the slice we use dot substring in OCR and
then we use square brackets X: Y in Python.
30:44
And these work very slightly differently whether you're using the OSA reference language
with substring or the Python slicing.
30:51
So if I want to get the characters PUTER pewter out of my phrase in OCR I would say
phrase dot substring 35, start at position 3 and then take the next 5 numbers.
31:09
That would give me character 3, character 4, character 5, character 6, character 7 and
that would give me that piece of text that I'm looking to extract.
31:19
Whereas in Python, again I start with the number 3 because I want to start position 3, but
then the second number isn't how many characters to take, it is the end position.
31:31
But remember the end position is exclusive.
31:34
So actions will give me characters 3456 and seven.
31:38
It won't return character 8, so the three is inclusive.
31:41
The 8 is exclusive.
31:43
So again, one more time, phrase dot substing 35 start position 3, take 5 characters gives
me pewter.
31:51
In Python, that is phrase 3/8, start at character 3, keep going until we get to character 7,
and again, that would return pewter.
32:00
In the OCR reference language, we've got the concept of dot left and dot right, where we
slice characters from the left of the string or slice characters from the right of the string.
32:09
That doesn't really have an equivalent in Python, but we can do that with slicing.
32:14
As you can see in the examples, in both OCR and Python, you've got dot upper and dot
lower, and these convert a whole string to uppercase or a whole string to lowercase.
32:25
For both.
32:25
If we want to concatenate or join strings together, we can just use plus.
32:30
So phrase equals computer plus space.
32:33
Plus science would give me computer science with a space in the middle and then the
last two at the bottom.
32:39
Here are maybe the more complicated ones.
32:41
We can find the ASCII value of a character by using ASC in OCR or Ord short for ordinal in
Python.
32:50
For example, ASCA or Ord A will give me 65 because 65 is the ASCII value for the capital.
32:58
AI can also take a ASCII value and convert that back to the original character by using
Chr short for character and that's capitalised in OCR or lowercase.
33:09
In Python, Chr 65 would return capital A the use of basic file handling operations, another
subject I know some people struggle with.
33:21
You don't need to know too much about this.
33:23
As long as you can perform some basic operations you should be fine.
33:27
Remember, files can be read from and written to by a programme.
33:31
Files must be open before use.
33:33
Files must be closed once operations are completed.
33:36
You must be able to read a line from a file, you must be able to write a line to the end of
a file, and you must be able to iterate through a file.
33:45
So if you look at a couple of simple examples of reading, for example, we have to write a
programme to read all the data from the text file data dot TXT and display each line on
screen in the OCR reference language.
33:57
That is, data file equals open data dot TXT while not data file dot end of file line equals
data file dot readline print line end while and don't forget your data file dot close.
34:09
In Python that is slightly different data file equals open data dot TXT.
34:14
Then we've got that R because we're opening it in read mode.
34:17
Then we say 4 line and data file print line, and then we have the datafile dot close.
34:23
Everyone, Please remember to close your file at the end.
34:27
Often in the exam, just closing it is worth a mark.
34:30
Often opening it is worth a mark.
34:32
So if you just open and close, you can get 2 marks out of four for a question like this,
even if you don't have any other lines of code writing.
34:40
So write a programme that repeatedly asks the user for a name and save that name to
the text file data dot TXT until the user types in end.
34:49
So it's a little bit more complicated because we're going to need some kind of while loop,
we're going to need some kind of input and we're going to have to write to a text file as
well.
34:57
In the OCL reference language that is datafile opendata dot TXT, we're going to create
data and just give it as a blank string.
35:05
While data not equal to end, data equals input enter name, if data not equal to end then
datafile dot writeline data and if end while datafile dot close.
35:17
In Python datafile equals open data dot TXT in West for write mode.
35:24
You can also use a for append mode if you want to add it to the end.
35:27
Technically, in Python, write mode will actually overwrite anything in a pre-existing file,
whereas append just adds to the end.
35:34
But we don't have to worry about that too much today.
35:37
Again, data is a blank string, while data not equal to end.
35:40
Data equals input.
35:41
Enter your name if data not equals end datafile dot writedata datafile dot close.
35:47
And again, that would get you all the marks in the exam.
35:50
And this would certainly be considered a fairly difficult exam question because you're
having to combine quite a lot of code together.
35:57
Now let's take a look at the use of records to store data.
36:01
A record is a data structure that allows multiple data items to be stored using field
names to identify each name of data.
36:08
A record is a data structure that allows multiple data items to be stored using field
names to identify each item of data.
36:16
To create a record, we must first define the field names that will make up each record.
36:20
We can then store the data under these field names in a database management system
DBMS using a table.
36:28
So a table is just a set of data.
36:30
It's got fields which are your columns.
36:32
It's got records which are your rows.
36:34
For example, this table is called Address Book and we can see that we've got the fields
First Name, Last Name, Telephone, and e-mail, and we've got four sets of example
records in there.
36:45
The Structured Query Language is a language used to access data stored in a database.
36:51
There are three main keywords to be aware of.
36:54
Select from WHERE always in that order.
36:58
SELECT identifies the fields to return from the database.
37:02
From identifies which table the data will be returned from and WHERE allows the
programmer to include criteria with only matching records being returned.
37:12
The WHERE is optional.
37:14
You need the SELECT and from.
37:16
You may or may not have a WHERE depending on what information you're trying to
retrieve.
37:20
The example here is SELECT first name e-mail from address book where last name
equals mills and this will return the matching data.
37:31
Graham and GW notexist dot cot So again, we're selecting the columns that we want, in
this case first name and e-mail from the address book table.
37:44
People often get the select and from mixed up you're selecting the fields from the table,
not the other way around.
37:50
And then we have our condition, something like where last name equals mills.
37:55
Please note here in the where clause, mills must be in quotation marks in the exam.
38:00
We'll usually take a mark off if you're not using the quotation marks here.
38:04
If we want to get all the fields from a table, we can use the wild card, asterisks or star
symbol.
38:11
So instead of writing select first name, last name, telephone, e-mail, I could just say say
select star from address book and this will return all the fields.
38:21
But if you did write every field individually, you would still get the marks.
38:24
But star is nice and easy and now everybody's favourite the use of arrays when solving
problems including both 1 dimensional and two-dimensional arrays.
38:34
The good news is most exams it's only one-dimensional.
38:37
I think they very rarely use two-dimensional arrays.
38:39
I think in the current series J277 they only use two-dimensional arrays in one of the
sample papers at the start.
38:47
They haven't actually used it in a real exam, which is probably because two-dimensional
arrays would be quite difficult to deal with in the exam.
38:53
But they might come up.
38:54
So we will study both.
38:55
A1 dimensional array allows as a programmer to store multiple items of data under a
single identifier.
39:02
Each item or element is accessed through a single index number.
39:07
A2 dimensional array allows a programmer to store multiple items of data under a single
identifier in a table structure.
39:15
So rows and columns and access each element using 2 index numbers to identify the
column and the row where the data is stored in the table.
39:24
Unless you are told otherwise, you can assume that the arrays start at position 0, but
please check any examples given in the exam in case they give you a one indexed array.
39:35
Arrays can only hold a single data type, so all the values in the arrays are integers or
reels or strings.
39:44
Technically Python doesn't have arrays, it only has lists and lists work a little bit
differently, but in the exam just treat them like simple arrays and don't try and use any
of the advanced Python features.
39:56
So let's imagine we have an array called colours and that just stores the values red,
green, blue, pink and yellow as strings.
40:05
And you can see here that red is position 0, green is 1, blue is 2, pink is 3, and yellow is
position 4.
40:13
In the exam, you don't actually have to create the array.
40:16
They'll give you the name of the array, they'll tell you what's in it, and you just need the
code to manipulate it.
40:21
They don't want you to waste your time actually writing out the initialization of an array.
40:25
In both OCR and Python, we can access any element in the array by using the index
position in square brackets.
40:32
So in both OCR and Python, colours square brackets 2 would give you the third item in
the list that is blue.
40:39
That's because arrays start at position 0 typically, so the third number is actually index
position 2, and in this case that is blue.
40:48
We can also replace the contents of something that's already in an array simply by
saying colours, square brackets 1 equals purple.
41:00
That will find the first position.
41:02
Well second really in the array, which is currently green, and that would replace that with
purple.
41:10
So it would now be red, purple, blue, pink and yellow because whatever is in index
position 1 gets replaced with purple.
41:17
So green is out, purple is in two-dimensional arrays.
41:21
We've got that table structure.
41:22
We have the columns, but we also have the rows.
41:26
When we want to access a position, we need to give the number of the column and the
number of the row.
41:31
For example, if I want to return the item salmon, I can say colours 1-2 in OCR.
41:38
In Python I have the two numbers in separate sets of square brackets, colours 1-2.
41:44
So go along, find column one, find row 2 and that would give me salmon if I want to
replace a value.
41:51
Works the same way as in the previous example.
41:54
I just give the column and the row and for example I can replace white with purple by
saying colours 31 equals purple.
42:01
Now in the exam.
42:02
Please read it carefully with those two numbers.
42:05
It's typically column and row in the exam, but double check to make sure isn't row first
then column.
42:12
They'll always give you an example in the text and the blurb of the question.
42:16
Just double check it.
42:17
What does it say for the example is, is it row, column, column, row?
42:22
Typically in Python, when we're programming it, it's usually row, column.
42:27
But obviously for the exam it's easier just to say, yeah, that's column, row, and we'll stick
to whatever the exam board we're using.
42:32
So often in exam questions you're going to be asked to iterate or loop through arrays,
workout a sum, workout an average, workout the highest workout, how to print out all
the values, etcetera.
42:45
So we're going to use this simple array called numbers for a few examples.
42:49
Remember, you don't have to create the array.
42:51
They give you an array of 1000 numbers.
42:53
You're not going to write out 1000 numbers to start with.
42:56
You just have to do the array manipulation.
42:59
They'll give you the name of the array.
43:00
You can assume it's already been created and use that in your examples, which is
exactly what we're going to do.
43:07
So a simple thing you'll be asked to do is calculate the sum or the total and output the
result of a series of numbers.
43:14
So some people will just say #0 plus numbers one, plus numbers 2, plus numbers 3, plus
numbers 4, and that might get you some credit.
43:22
But what we really want you to do is loop through the array and then come up with the
total.
43:28
So this is how we do it in the OSCR reference language.
43:31
Initialise your total variable.
43:32
Total equals 0 four X = 0 to four.
43:36
Why is it zero to four?
43:38
Well, let's have a look at the top.
43:39
Here we have 0124, 3:00 and 4:00.
43:48
So generally that is the first thing I do when I see an array.
43:52
I write the index values on the top so I don't make any silly mistakes.
43:56
So in Oscar reference language are 4 loops.
43:59
Both numbers are inclusive, so go from zero to four and then total plus equals numbers X
plus equals if you don't know is just a programming shortcut.
44:09
It just means the same as total equals total plus numbers X.
44:13
So whatever number X is add to total and then store as total next X and print total.
44:19
Notice if you don't want to have to count up the total number of values there, you can
replace the four with numbers dot length -1 so I could say four X = 0, 2 numbers dot
length -1 so the length of this is five.
44:35
There are 5 numbers stored.
44:37
If I wanted to go from zero to four, I have to subtract 1.
44:41
In Python I would do this like so total equals zero, 4X in range 05.
44:47
So again, we're starting at position 0.
44:50
Python.
44:50
The second number is exclusive, so it's one more than we need.
44:53
So instead of saying 4 we say 5 total plus equals numbers X printtotal.
44:59
Again I can use the length of the array instead of the final number there the five, so I
could replace 5 with Len numbers.
45:08
I don't need to use the -1 in Python.
45:11
I can just say 4X in range 0 Len numbers, and I don't need that -1 like I did in the OCR
reference language because the number is exclusive in Python, and that's why we have
that exclusivity for the end condition in an array.
45:26
People always ask me why we do that, and that's because when we're manipulating
arrays, we don't have to keep adding on this -1 all the time like we have to do in some
other languages.
45:36
If I want to calculate the average very similar to working out the sum or the total like we
did before, I just then have to take the total and divide it by the number of numbers, in
this case 5, and that would give me the average.
45:52
A more complicated one is calculating the highest value in a set of results.
45:57
So in the OCR reference language highest equals #0.
46:00
So whatever is in the first position, position 0 in the array, that becomes the highest
value.
46:06
So that would set it to three in this example.
46:08
Go through the rest of the array.
46:10
We can ignore position 0, we've already checked that.
46:13
So for X = 1 to four, if numbers X greater than highest, then highest equals numbers X.
46:18
So check the value of whatever is the next number in the list.
46:23
If it's bigger than highest, then that number becomes the highest, and at the end, we
print out the highest.
46:28
Python is very similar.
46:30
Highest equals #04X in range 15.
46:33
Again, exclusivity there.
46:34
For the final number, again, we check to see if numbers X is bigger than highest.
46:38
If it is, we set highest to whatever the value of numbers X is, and then we print it out at
the end.
46:44
If you want to find the lowest, you can probably work out how to do that very simple.
46:48
Again, we set lowest to #0 we loop through everything in the list.
46:54
If the current number we're looking at is smaller than lowest, then that number becomes
lowest.
46:59
And then we keep going through the whole list and we print lowest at the end.
47:03
Sometimes you might be asked to reset the contents of an array, which might be replace
all the numbers with zero or replace all the text in an array with blank strings.
47:13
And we would do this like this.
47:15
So we've got the colours array, we've got red, green, blue and pink and yellow.
47:18
We want to reset all that, so we just loop through every element in the array and we just
set every position to a blank string.
47:26
If it was a set of numbers and we wanted to replace everything with say a zero, we would
just say 0 instead of a blank string here, and that would just reset everything.
47:35
If we're dealing with two-dimensional arrays, it becomes a little bit more complicated
because we have to loop through all the columns and all the rows, so we're going to have
to have this nested for loop structure again.
47:46
If you get some kind of array like this, you always want to be writing in those index
values because otherwise you can get mixed up in your head.
47:54
So column zero, column one, column two, column three, column 4, row zero, row one,
row 2.
48:05
Again, I don't have to create the array, I can assume it's already been created.
48:09
It'll give me an example so I know if it's row column or column row.
48:13
In this example, I want to calculate the sum of the every number in this array.
48:19
I initialise my total.
48:21
I loop through all the columns.
48:24
For each column I loop through all the rows.
48:26
Or the other way around, doesn't really matter.
48:28
Then I add whatever I've got to my total, bearing in mind I need the two index positions
in both OCR and Python, and then I can print the total at the end.
48:37
So that nested for loop.
48:39
Make sure you get your indentation correct here.
48:41
It's not too difficult to do this, but in the heat of an exam it can be quite complicated.
48:45
You can kind of memorise this.
48:47
That gives you the sum of the total.
48:49
If you wanted to do the average, you could just divide it by the number of numbers at the
end and that would also give you the average.
48:56
And you can basically do the highest and the lowest and the reset just by extending the
code that we did previously to have that second nested for loop.
49:06
How to use subprograms to make structured code?
49:10
So subprograms or programmes split up into multiple sections.
49:14
This makes the code easier to read and maintain, reduces the size of the code, and
promotes code reuse without copying and pasting.
49:22
There are two types of subprogram, procedures and functions.
49:25
Procedures are a subprogram that does not return a value to the main programme, it just
does something.
49:32
Functions are a programme that does return a value to the main programme.
49:36
They will always have the return keyword used in the function itself.
49:41
So let's take an example.
49:42
We're looking at procedures both in OCR and Python.
49:46
In OCR reference language, procedures start with the keyword procedure.
49:50
Then we have the name of the procedure.
49:52
They'll probably tell you what that is in the exam question.
49:55
Then we've got any parameters.
49:56
We need parameters or values that are passed to the programme so that it can make
use of them.
50:02
Then you're going to have a little bit of code in there to do something, and then you're
going to have the end procedure to mark the end of the procedure.
50:08
In Python, we don't have the procedure keyword.
50:11
We use def for define, so we just use def whether it's a procedure or a function.
50:16
We have the name and the parameters and then we do the code that we need to and we
know this add subprogram is a procedure, not a function because we're not returning
anything for not returning it, it's a procedure.
50:30
If we are returning something, it is a function.
50:32
For functions in the OSO reference language, we use the keyword function.
50:36
Apart from that, it works very similar except we have this return total line because the
function was returning a value to the main programme.
50:44
Again, Python, we don't have the function keyword, we just define it using def.
50:49
We have the name and the parameters, but then we know that this is a function because
it is returning the total.
50:54
So again, functions are always going to return something.
50:57
Procedures never return anything.
50:59
That's how you know the difference, and that's what you have to be aware of when
you're coding them.
51:03
Once defined, subprograms can be called at any point in your main programme, or
indeed from other subprograms.
51:10
You may need to pass values to a subprogram if they have parameters.
51:14
If you call a function, you have to make sure you have a variable ready to store the value
returned.
51:21
Add.
51:21
As we know from the previous slide, there was a procedure, so we just call that with the
name of the function plus any values it requires.
51:31
They don't have to have the same name, they can have different names.
51:33
It's the values themselves.
51:35
They'll get moved and passed to the procedure for the function addition.
51:39
Again, we have to pass it the values it requires, but we also have to have a variable
ready to actually store the answer when it's returned because addition is going to work
out with total and send that total back to the calling code and I'm going to store that as
answer.
51:54
And now we have random number generation.
51:57
Random numbers can be generated by programmes.
51:59
To generate a random number from one to 100, both inclusive.
52:03
OCR reference language number equals random one, 100.
52:07
Python we use number equals random dot randint one 100 and that will give us a
number between 1 and 100 inclusive generated randomly.
52:16
Technically in Python you should need to import random if you're actually coding this,
but in the exam you don't have to worry about importing library functions, so you can
just use random dot randint without the import and you will still get full credit.
52:29
2.3 Point 1 Defensive design Defensive design considerations Defensive design involves
thinking about problems that could potentially occur and preventing them before they
happen.
52:42
Anticipating misuse is thinking about the ways users could cause the programme to fail.
52:47
This could be accidentally or deliberately, but both have to be dealt with.
52:52
Authentication is the process of establishing a user's identity so that only authorised
users have access.
52:59
This could be through username and password, possession of electronic key, device or
account biometrics, for example fingerprint scans.
53:10
Input validation is the process of checking data when it is entered to see if it conforms to
a rule.
53:16
This can check that the data is sensible, but cannot show that is correct.
53:21
For example, O 120-234-3443 is a sensible phone number, but is it the user's real phone
number?
53:29
Input verification is the process of checking that data has been entered correctly.
53:34
For example, making people enter a phone number or e-mail address twice input
sanitization cheques and modifies any input before passing it on to the next process.
53:45
For example, changing the case maintainability is when the original programmer has
deliberately made a programme straightforward to understand and modify.
53:55
To make sure your code is maintainable, you should indent the programme structures in
the code.
54:00
Add comments to the code to identify what each section does and how the programme is
intended to work.
54:06
Use meaningful variable names to identify the purpose of each variable.
54:11
Use subprograms to reduce the amount of code and improve efficiency, and use
whitespace to make the code easier to read.
54:19
2.3 Point 2 Testing The purpose of testing is to ensure the programme functions as
expected.
54:26
You have iterative testing when you test during the programme development.
54:31
So as the programme is being programmed.
54:33
Then we have final testing, sometimes called terminal testing.
54:37
This is testing after the programme is finished identifying errors.
54:42
We have syntax errors and we have logic errors.
54:45
A syntax error is when the rules of the programming language are broken.
54:50
Some examples are variables not declared before use, missing out a bracket or a
quotation mark, incompatible data types, assigning values incorrectly.
55:01
For example, writing 3 + 4 answer rather than answer equals 3 + 4 incorrect variable
names.
55:08
For example, getting the spelling incorrect or capitalising 1 and not capitalising it when
you use it in the future.
55:16
Syntax errors are generally easier to find in a programme.
55:19
If you're having to do that in the exam, you're just looking for these kind of basic errors.
55:24
Logic errors are when the algorithm produces an unexpected result.
55:28
In other words, the programme does not do what the programmer intended.
55:32
These can be a little bit more difficult to find.
55:35
Sometimes you might have to do a little trace table.
55:38
Common mistakes that result in logic errors could be conditions that cannot be met in
conditional statements.
55:44
So it can never be false, it can never be true, etcetera.
55:47
Divisors that can reach 0, so division by zero errors, infinite loops.
55:52
The loop just continues forever.
55:54
The actual algorithm is just incorrect and it doesn't do what the programmer meant it to.
55:59
We could have incorrect expressions, calculations that are incorrect, or we're missing
brackets that could affect the precedents, and things like forgetting the array indexes
start at 0 commonly, not one.
56:13
Selecting and using suitable test data.
56:15
Test data should be chosen so that systems as a whole can be tested destructively,
checking for errors whenever they occur so you're not just testing that it works when the
data is correct.
56:26
You have to test when the data is wrong to make sure your programme responds
appropriately.
56:31
When we select test data, we should be doing normal, boundary, invalid, and erroneous
test data.
56:37
Normal is data that is typical input for the system.
56:40
This should be accepted by the programme without causing errors.
56:44
Boundary test data is data that is of the correct data type but is on the very edge of
being valid.
56:51
Boundary test data should be accepted by the programme without causing errors.
56:56
Invalid is the correct data type, but it is outside of the accepted limits of the programme.
57:03
Invalid tested, it should be rejected by the programme and erroneous is the data is of the
incorrect type and should be rejected by the system.
57:12
So the example is if a programme is expecting a number, a string would be erroneous.
57:19
And here's an example of this just to give you kind of a very simple test table to show
you what I mean.
57:23
If you have a programme that takes a number from one to 10 inclusive and prints it out
on screen, these are maybe a set of tests that you could do.
57:31
So 5 would be an example of normal test data, and that should be allowed.
57:36
One and 10 are boundary data.
57:39
They are of the correct data type and they're on the very edge of being correct.
57:44
If they're any more, any less they would be wrong.
57:46
So they're both allowed, but they're on the very edge.
57:50
0 and 11 would be examples of invalid test data.
57:54
They are of the correct data type, but they're beyond the upper and lower boundaries of
what is acceptable in the programme.
58:01
So anything less than one or greater than 10 would be acceptable in the exam.
58:07
And if I entered the string 5, that would just be erroneous.
58:11
So all the invalid and the erroneous data should be rejected.
58:15
The normal and boundary data should be allowed.
58:18
Refining an algorithm means to improve the code.
58:21
If testing has picked up any errors, an obvious improvement would be to fix the problem.
58:26
Other attempts to refine the algorithm may make the code more efficient or
maintainable.
58:32
2.4 point 1 Boolean logic.
58:37
Boolean logic uses 2 values, true and false.
58:40
These are represented in a computer system using binary one and 0 values.
58:45
For GCSE J277 syllabus we need to learn 3 logic gates and their associated truth tables.
58:52
These are not and or so here you can see we've got the not, we've got the and we've got
the OR.
58:59
Make sure you practise drawing them so they're clear.
59:02
Make sure you learn the truth tables.
59:05
A lot of very easy questions in the exam, just drawing the gates, doing a simple test
table, not test table, doing a simple truth table will get you the marks, but you do just
have to learn these.
59:16
These three logic gates can be combined into more complex logic systems.
59:22
So here we've got not A&B.
59:25
So we've got A&B going into the AND gate that's being fed through a not gate to reverse
the output.
59:31
What would the truth table be like?
59:33
Well, see here we've got A&B and then we've got R, which represents the output of A&B.
59:40
And then we're going to negate that with the knot gate for output.
59:44
PA and B are both 0.
59:46
Then R would be 0 and then P would be one.
59:49
If A&B are zero and one, then we would have R being zero and P being one.
59:54
If A&B are one and 0, R would be 0P would be 1.
59:58
And if A&B are both, 1R would be 1 and P would be 0.
1:00:02
Again, we've got something similar here.
1:00:03
We've got A&B or C.
1:00:06
So A&B are going into the and gate.
1:00:08
The output R Plus another input C are going into the OR gate and then we have P and
then again we have the truth table here.
1:00:17
If you look at the truth table, sometimes students are a little bit confused of how to do
these larger truth tables if they have to.
1:00:22
But if you notice that in binary it's 012345, so on and so forth.
1:00:29
It's just going down in sequence.
1:00:30
So if you know your binary, you can write that down quite simply and then just work out
any outputs.
1:00:37
We can also apply logical operators and truth tables to solve problems.
1:00:41
Reducing real life problems down to boolean logic statements can help us decide what
inputs are needed to produce certain outputs.
1:00:49
So imagine a family looking to book a holiday.
1:00:52
They have a budget of £2000.00 for the holiday and they would like this to be
somewhere with the pool.
1:00:57
However, if a holiday in the USA was available at this price, with or without a pool, they
would be happy.
1:01:03
We can construct this situation as a logic statement.
1:01:06
Let P be the outcome of being happy with the holiday.
1:01:09
The inputs can be defined as a equals cost of £2000 or less, C is has a pool, C is in the
USA.
1:01:18
So the situation is equivalent to the logic statement P = A and B or C The truth table for
this logic statement can therefore be below.
1:01:28
So we can again go through AB and C again it's just 012345 etc.
1:01:34
Then we can work out B or C and then we can work out P That would give us the truth
table that you can see here.
1:01:42
2.5 point 1 languages.
1:01:46
Low level languages means machine code and assembly language, whereas high level
language is the languages that you're most familiar with, Python, C, Java, etcetera.
1:01:56
Low level languages using binary or mnemonics to represent instructions whereas high
level language use English like keywords.
1:02:04
Low level languages are hardware dependent.
1:02:07
High level languages tend to be hardware independent.
1:02:10
They can learn.
1:02:11
They can run on different platforms and different systems.
1:02:14
Translators are used to convert programming code into machine code for the computer
to process.
1:02:20
There are three types of translator.
1:02:22
Assembler translates low level assembly code into machine code.
1:02:26
Compilers translate an entire high level programme into executable machine code at
once, and interpreters that translate high level programmes to machine code line by line
in real time.
1:02:38
Again, we need to be familiar with the characteristics of compilers and interpreters.
1:02:42
So compilers translate the whole programme in one go into machine code and then run it
afterwards, whereas interpreters translate one line into machine code, run it, and then
repeat for the next line.
1:02:53
Compilers produce an executable file at the end that can be run independently.
1:02:58
Interpreters do not produce an executable file compilers.
1:03:02
While once compiled the code does not need to be translated again, with an interpreter
the programme needs to be translated every time the programmer is run.
1:03:11
Compiled we can distribute the executable so the user does not need to use or see the
source file, whereas with an interpreter the user needs the source code file and the
interpreter both to run the programme.
1:03:24
Compile code tends to run very quickly.
1:03:27
Interpreted code tends to run more slowly because it has to be reinterpreted every time
it's run.
1:03:32
2.5 Point 2 The Integrated Development environment or IDE An IDE integrated
development environment is a comprehensive set of tools used to develop programmes.
1:03:44
You have to be familiar with some of the common features of an IDE, and these might
include an editor to actually write the code.
1:03:51
Usually these are optimised for one or more languages.
1:03:54
Error diagnostics such as tools for debugging step by step progression through a
programme, a build feature that compiles and links the other needed parts of the
programme, version control, a runtime environment to allow the programmer to run the
code and see the output from the ID itself, and a translator such as a compiler and
possibly an interpreter.
1:04:17
Well there you go guys, that is the whole video.
1:04:19
I hope there was something in there that was useful to you.
1:04:22
Hopefully that was a useful revision resource.
1:04:25
I'm sure there are quite a few typos here and there, but I don't think there's anything too
serious.
1:04:30
Cross fingers Touchwood, good luck with your GCSE exams and I might see you again in
the future.