The ULTIMATE IGCSE Computer Science Paper 2 Revision
By Pup Studies
Summary
Topics Covered
- Mastering Pseudocode Syntax: Key Rules for IGCSE Success
- Indentation Rules Affect Your Exam Marks
- Else If Is Forbidden in IGCSE Pseudo Code
Full Transcript
[Music]
Hi, I I go by Puppy in Discord and today we'll be going through the content of
IGCC computer science paper 2 as well as um attempting a paper 2 and um teaching you guys how I approached the 15 marker.
Uh last May June May June 2024 I have taken the exam and got top in country so you'll be in good hands and Ahmed will
be co-hosting the session. So say hi.
Hello everyone. I'm Ahmed. I'm CS helper in the in the server and I appeared for my CS exam last year in October November.
Yes. Okay, let's
start. So, yeah, covering chapters 7 to 10, solving paper two. Um, whatever
skill level you are, it will be suitable for you. It will be recorded and posted
for you. It will be recorded and posted on the channel that's linked in the chat right now. And uh there will be a Q&A
right now. And uh there will be a Q&A slide for after every chapter. So, you
so you guys can ask questions. However,
you can still ask questions and um Ahmed will be answering you or I will be depending on who's speaking. Yeah.
Yep. You can ask questions in chat as puppy goes along and I'll be answering them in chat.
So we'll start off with chapter 7 with the program development life cycle as well as you know inserting chapter 8 in
the design part because um pseudo code is in the design aspect and it's quite hard to introduce the whole chapter 7
without touching on pseudo code. So
yeah so first what is the program develop life cycle? So let's say you were trying to you know make a program.
These would be the four stages you will conduct um to successfully launch the program. First you analyze, then design,
program. First you analyze, then design, then code, then test. And also notice how it's a cycle. And that's because um for example if the program's hype starts
to die down it uh we might want to go through the cycle again analyze why um the hype is dying down and what are the
new requirements of the program. So
yeah, first in the analysis section there's abstraction. In
abstraction you would be simplifying the problem rem removing unnecessary details or essentially just you know removing parts
that the the client or whoever is giving you the task to do the program. you're
just removing the unnecessary parts. And decomposition is after you
parts. And decomposition is after you have abstracted the problem, um you'll break it down into smaller parts and chunking it so it's easier to
manage. And now for the design
manage. And now for the design section there is um the structure diagram, the flowcharts and the pseudo
code. So when you go about designing a
code. So when you go about designing a program you would be uh you can represent the the program in
these three types and so yeah so let's try a structure diagram. So in a structure diagram let's
diagram. So in a structure diagram let's let's try this exam question. So a
satellite navigation system is an example of a computer system that is made up of subsystems. This means that you know there's a top- down hierarchy
where there are subsystems down and down and part of the system has allowing the user to enter details or select a previously saved
destination. You could also display
destination. You could also display directions in the form of a visual map or list. And so now it's asking us to
or list. And so now it's asking us to draw a structure diagram to represent that.
My easy formula trademarked um is first we'll have the big system.
So we give the name of the overall system then the subsystem with input output processes or storage and try to apply
um those concepts into whatever the scenario is and then the further subsystems you name the action method.
So for this one, first you would name the quoteunquote big system as um the satellite navigation system.
Then there's the input part. So for the input part you would be um saying
input which could be new or it could be saved.
And um there is also the output which could be a visual map or a
list and you know just so everything is clear I have the answer on the next slide.
One second here. But don't worry about um you know
here. But don't worry about um you know not matching the mock scheme exactly because the mock scheme is quite lenient. Here is the actual mock scheme
lenient. Here is the actual mock scheme and they just ask one mark for hierarchical structure, one mark for suitable names for subsystems, one mark
for identifiable inputs and one mark for identifiable outputs. So as long as you
identifiable outputs. So as long as you know um you're answering structurally just like this then it'll be
fine. Next we have
fine. Next we have flowcharts. So, a flowchart, as you guys
flowcharts. So, a flowchart, as you guys know, um is a series of flowchart symbols connected by a flow line here, um forming a step-by-step idea of the
algorithm.
So, I'll just show you guys an example and uh we'll refer back to what each symbol means. First, the start. So, yeah, we're
means. First, the start. So, yeah, we're just starting the program here.
Then we print out we print out the menu like this program would be uh a cashier system. We print out the menu. Then we
system. We print out the menu. Then we
initialize the total um total price of the bill. Then we output asking for how
the bill. Then we output asking for how much the item price is. Input the price.
Total it up. And um if the user wants to end it just there, they would enter minus one. it would go back. No, and it
minus one. it would go back. No, and it would just output and stop. Else it
would go back and ask for the next item. And notice how I total equals
item. And notice how I total equals minus uh equals 1 instead of zero. And
that is because minus one um the last item would be minus one and that would cancel out with the one that it started
with. Now what each of them mean?
with. Now what each of them mean?
So first this one is a sub routine. So it it will run a separate
routine. So it it will run a separate and non-length flowchart that is um in another place. Then this is called a process
place. Then this is called a process box. So you might assign variables, you
box. So you might assign variables, you might calculate, you might um yeah and parallelograms are called input or output boxes. So you'll be
outputting a phrase or inputting um for an identifier. Then that is another process
identifier. Then that is another process box that is called a decision box. And
instead of an if you'll be an is and uh there would be yes or no. So
yeah and then a stop. Those are called terminators start and stops. Okay. Um that would be the
stops. Okay. Um that would be the program development life cycles analysis and design section and in the design section there's pseudo code. So Amid
will be teaching you guys the pseudo code syntax.
Okay. So now we're going to start with chapter 8 in which we're going to first cover pseudo code basics syntax variables and arrays. Then input outputs library routines operators and
selection. After that, we are going to
selection. After that, we are going to have a question and answer session. Then
we're going to go to file handling uh iteration and sub routines. Okay, let's
routines. Okay, let's go. Okay, so when we're using pseudo
go. Okay, so when we're using pseudo code to construct a solution to a problem, we need to follow a certain set of rules. Okay, before I carry on, am I
of rules. Okay, before I carry on, am I audible to everyone? If I'm not, you can right
everyone? If I'm not, you can right click on my user and increase user volume.
Okay, perfect. Okay, so you are supposed to follow a certain set of rules. Now,
these rules are called your syntax. Now,
some very basic rules would include that your keywords such as outward, close file, read, uh, repeat, they always need to be in uppercase. Secondly, your
identifiers, they need to be in Pascal case. For example,
case. For example, uh, team names and student marks. Now
you can never put a space between those two and you can never use an underscore in your identifiers. Okay, moving on. When now
identifiers. Okay, moving on. When now
we're going to talk about indentation.
Now when a new line is being made within a statement, we indent the new line by four spaces. Indent means that we're
four spaces. Indent means that we're going to leave four blank spaces from the left and then continue with our statement. When assigning when assigning
statement. When assigning when assigning to variables in pseudo code, we use the arrow key in which we use the we use the
arrow key and we ident we put the name of the identifier, the arrow key and then the value we are assigning. The
value could be another variable, the value could be uh the value could be an expression, anything. We have a small
expression, anything. We have a small example of pseudo port towards the left of the slide towards the right side of the slide. And here you can see an
the slide. And here you can see an example of indentation where when we make uh when we when we make a statement inside of the for loop we leave four
spaces. Okay, that's it for basic
spaces. Okay, that's it for basic syntax. Let's move
syntax. Let's move on. Now we're going to start with
on. Now we're going to start with comments. Comments are added to make our
comments. Comments are added to make our program more readable and maintainable.
So for example uh this is a program that swaps the values of two variables x and y. Now
to a new programmer who has not written this code this might be confusing. So we
can add comments preceded by double slashes and a space. And then we write and now these comments they are ignored by the compiler. So they aren't part of
your code. They're basically added as an
your code. They're basically added as an aid to you in the future or some other programmer to understand the function of your code or understand the function of specific parts of your code. That's it
for comments. Let's move
on. Okay. Now we have data types.
Firstly, data types we have in identifiers we always use Pascal case.
Let's remember that. And we can only use letters and digits when uh defining our data types. Okay, so A to Z and 0 to 9.
data types. Okay, so A to Z and 0 to 9.
And keywords such as input and output should never be used as your identifiers. Now integer is our first
identifiers. Now integer is our first data type. An integer is basically a
data type. An integer is basically a whole number. It could be five, it could
whole number. It could be five, it could be minus3, it could be minus 10. A real
is a decimal number. So in a decimal number, you can you need to have a number on either side of the decimal place for it to qualify as a real number. for pseudo code. Uh a char is a
number. for pseudo code. Uh a char is a single character. Okay. And it is
single character. Okay. And it is enclosed in single quotation marks unlike a string. A string is a sequence of zero or more characters and is
enclosed in double quotation marks. Now
what's important is that a string can also have zero characters. So this is important when we're doing things like presence checks. So a string can have
presence checks. So a string can have zero characters as well. Lastly, we have booleans. So the booleans are basically
booleans. So the booleans are basically variables that store the logical state of true or false. Okay, let's move
false. Okay, let's move on. Next slide. Okay, declaring
on. Next slide. Okay, declaring
variables and constant. Firstly, a
variable is a variable can store many values. A variable can have a new value
values. A variable can have a new value written to it in the middle of your code. You declare a variable as follows.
code. You declare a variable as follows.
Firstly, you use the declare keyword.
You use the declare keyword again in capitals followed by the identifier and then the data type in capital. For example, declare counter as
capital. For example, declare counter as an integer or declare flag as a boolean.
Now this is different when we work with constants. With constants we don't
constants. With constants we don't mention the data type. We only mention the literal. The literal are the values
the literal. The literal are the values that a data type can store. For example,
constant pi we use the assignment arrow 3.14.
Okay so 3.14 is going to be stored to pi. For
constants, you can in pseudo code, you can never assign another variable to a constant. You can never assign uh uh
constant. You can never assign uh uh another constant to a constant or an expression. You must always uh assign a
expression. You must always uh assign a literal to a constant. And a constant should always be assigned at the start of your code. This isn't necessary, but it's good practice because your constant
cannot be changed once it's assigned.
Moving on.
Okay. 1D arrays. An array is essentially a data structure that can that contains several elements of the same data type.
So an array can only store one type, one data type. So you declare an array as
data type. So you declare an array as follows. The declare keyword. Then
follows. The declare keyword. Then
moving on. Okay. Uh in chat guys, ping puppy if you have any questions. Okay.
he'll be answering your questions in chat. Okay. Declare you put in the
chat. Okay. Declare you put in the identifier of the uh array you want to use and then you put in the lower bound and then the upper bound. Now it's
important that your upper lower bound should always be smaller than the upper bound and your lower bound is the first index of your array and your upper bound
is always the last index of your array.
So the index of your array is essentially the row. For example, uh the fourth index in the array you see on screen would be Sarah. So if we were to
use this and for example, if we were to output names index 4, we would do this by enclosing four in square brackets, it would output the string Sarah.
Okay, let's move on. That's it for this slide.
Okay, for assigning content to an array, we can also you we use the assignment arrow. For example, names five and we
arrow. For example, names five and we use the assignment arrow of David, it would assign the value, it would assign the string David to the fifth index.
Now, you can see in the array it says Jonathan on the fifth index. Once we
assign it David, Jonathan is overwritten and now the fifth index will be David.
Okay, let's go.
2D arrays. 2D arrays are like 1D arrays but they are like a table because they don't just have rows they have columns as well. So we declare them similarly to
as well. So we declare them similarly to a single to 1D arrays but after that we after adding the number of rows we also add the lower bound of columns and then
the upper bound of columns. Okay, if you don't understand rows and columns rows are the these these are your rows.
Okay, these are your rows and these are your columns. Okay, so as you can see as
your columns. Okay, so as you can see as in the when we declare, we declare student marks as array 1 to 3, 1 to two.
When we're declaring, we always declare the rows first. Okay, you can if you keep forgetting which one is which one comes first, remember it as remote control, rows, columns, remote control.
Okay. So the rows are declared first.
These as puppy mark these are your rows and then the columns columns 1 2. Okay.
So these are your columns. Now when we use 2D arrays we
columns. Now when we use 2D arrays we again once again we do rows first and then we do columns. For example, if you were to do output student marks square
brackets 2, 1, we would get the marks of student B in history, which would be 22, right? So, I hope that makes sense.
right? So, I hope that makes sense.
Okay moving on. Chapter 8. Okay, that concludes
on. Chapter 8. Okay, that concludes syntax, variables, and arrays. We're now
going to be moving to input, outputs, and library routines. Let's go.
Okay, first we input an output. This is
pretty this is pretty simple. Okay, when
if you want to input a value into an identifier, if you want to prompt the user to input a value, we use the input keyword followed by the identifier that we are writing to. Now what this would do it was it would prompt the user to
enter a value and then that value would be written to the identifier. In
outputting, we use the output keyword and then we would put in the expression that we want to be output. For example,
if you look to the bottom of the slide, we prompt a user to enter your name and then it inputs the name into student name. And
name. And uh you might be confused about what expression means in output. Okay. So
over here you can see in the last line output student name student name is going to be output the value inside of student name. Let's say the value is
student name. Let's say the value is John. The string inside student name is
John. The string inside student name is John. got core we the score of that
John. got core we the score of that student is 22 and then we have the string marks. So now once we run this
string marks. So now once we run this this would translate to John got 22 marks. I hope that makes sense. Okay
marks. I hope that makes sense. Okay
let's move on. Now we have arithmetic operators. We have the very simple ones
operators. We have the very simple ones addition subtraction multiplication division and raising to the power of.
These are very simple but what most people get confused about is integer division and modulus. Firstly, what
integer division does is it returns the quotient of a division of a division operation with the remainder discarded.
For example, 10 / 3 it leaves us a quotient of three with a remainder of 1.
So div d 10 3 gives us the value of three. It gives us the quotient and
three. It gives us the quotient and discards the remainder. Now modul what modulus does is it finds the remainder of a division operation and then
discards the quotient. So for example 10 / 3 leaves us a quotient of three and a remainder of 1. Now mod 10 3 would give
us a value of 1 as the remainder of the mathematical operation is one. Okay, I
hope that makes sense. Now we're moving on to logical
sense. Now we're moving on to logical and boolean operators. Logical operators
are pretty straightforward. Equal to,
less than, less than or equal to, greater than, greater than or equal to, and not equal to. Now an examples towards the right. If value 1 equals to
value two, then we are going to output the statement values are the same and if. Now for those of you who don't know
if. Now for those of you who don't know for loops at the moment, what basically this will do is it will check to see if value 1 equals to value 2 and it will
output the values are the same. If it
is, it's pretty simple. Now in the second example, if value 3 is greater than value four, then it will output value 3 is greater than value four.
Pretty straightforward. If it's not greater than value four, it will not output that statement. Now uh logical the result of a logical operator is
always uh a boolean state. For
example, the we have the last example is different. Now value if value five and
different. Now value if value five and value six are not equal to each other this will translate to true. If value
five and value six are different uh this will translate to true and the boolean state true will be stored in the is different variable.
Okay, moving on to boolean operators. The boolean operators are
operators. The boolean operators are boolean operators puppy. Okay, and or and not. Now moving towards the right in
and not. Now moving towards the right in the example. If answer is smaller than
the example. If answer is smaller than or equal to zero and answer is greater than or equal to zero then output value
is in range otherwise else output value is out of range. So what essentially this does is it's the same as the value above, but what it will do is it'll
check to see if both these expressions are true. Both of these expressions need
are true. Both of these expressions need to be true in order for the then statement to be executed. If one of them is true and then the other is false, the value will still not be executed as it
requires both conditions to be true.
Moving on, let's go to the next slide.
Now we have library routines. Uh firstly
we're going to start with string operators. We have four string operators
operators. We have four string operators length, lc case, ukase and substring. So
what length what length does is it takes the length it returns the length of a string. For example, if we input the
string. For example, if we input the string happy days, it will return the value 10. It will return the integer
value 10. It will return the integer value 10. This is because there are 10
value 10. This is because there are 10 characters in the length in the length string. Okay? And this always includes
string. Okay? And this always includes the space. You always need to count the
the space. You always need to count the space as a character also. Now the LK case what the
character also. Now the LK case what the LKS function does is the LKS functions returns the LK case function returns a string in lower case as seen in the
example. The UK function returns a
example. The UK function returns a string in uppercase. All the characters will be uppercase. Okay. Now substring
what's substring? Substring is a little confusing. What substring does is it
confusing. What substring does is it returns the part of the string starting from the it returns a part of the string starting from the start character that
we give it and it will be of the length we give. For example, if we give it the
we give. For example, if we give it the string happy days and we're starting at uh the second character we're going starting at a and the length of the and
the length of the output string is to be four. We're
going to count four letters A, B, P, Y.
So substrings substring happy days 2 4 will return with the string happy. Make
happy. Make sense? Okay, let's move on to the next
sense? Okay, let's move on to the next slide. Now we have round and random
slide. Now we have round and random which are the last operators. Okay, random returns a real
operators. Okay, random returns a real number from 0 to one inclusive.
So if you move on to examples, you'll see that random running random would return a value like 0.5 53575 46 whatever. Okay, a very large decimal number. Now in most use cases
decimal number. Now in most use cases this would be pretty useless as it returns a random decimal number between 0 and 1. That's why if we wanted to say
make an output a number between 0 and 5, we would do random* 5. Now what's
important to note here is that this would output a number between 0 and five not 1 and five. If you do randoms times 5, it will never output a number between
1 and 5. It will output a number between 0 and five. Okay? So that's something that most students confuse. Again, a
decimal number of that size will be essentially useless to most of your cases. So that's when the round function
cases. So that's when the round function comes in. Now standalone what the round
comes in. Now standalone what the round function does is that it returns the value of a variable rounded to the amount of decimal places that you specify. For example, rounding
specify. For example, rounding 3.1415 to one decimal place would return with the would return with 3.1. Okay. So
simple enough. So how are we going to use round and random together to return a whole number between say 0 and six?
Round. Firstly we're going to use the round function. Then in the brackets
round function. Then in the brackets we're going to put random * 6 to zero places. Now what random* 6 is going to
places. Now what random* 6 is going to do is it's going to make random decimal number between 0.0 and 6. So that's the
random part covered. Now this random value will exist inside of the round inside of the round function. So the
round function will round it off to zero decimal places. So if the value is
decimal places. So if the value is 4.23517 2 3 5 1 73 it will round the value off to four and the final result we get will be four. Make sense? Let's
move on. Okay. Selection. Now we're moving on
on. Okay. Selection. Now we're moving on to selection. If statements basically
to selection. If statements basically now with selection we have two types of selection in pseudo code. If statements
and case of statements. We're going to start with if statements. Firstly, if
statements only run if a condition is true. We provide if statements with a
true. We provide if statements with a certain condition. The program checks to
certain condition. The program checks to see if that condition is fulfilled and then it executes the statements we give it. Now, an if statement can be written
it. Now, an if statement can be written either with or without an else statement. In the first example, we do
statement. In the first example, we do it without an else statement. If student
marks is greater than 40, then output pass. Okay? So if student marks will be
pass. Okay? So if student marks will be greater than 50 it will output pass and if you always end if okay when you write with an else statement your else
statement you write if a condition is fulfilled then output a certain statement if this condition is not fulfilled the statements written under the else statement will be under the
else clause will be executed. So if
student marks is greater than 40 then out would pass else output fail. So if
the student marks is 23 for example, it would output fail and then we close it off with end if. Now then let's go on to the next slide. We're going to do nested
ifs next. Okay, nested ifs are if
ifs next. Okay, nested ifs are if statements inside of an if statements and this has many use cases. In IGCSC
pseudo code, you will only be required to write up to three levels of nested if statements. Now if we move to the
statements. Now if we move to the example here, puppy, if you can bring the pointer. Now we have the first if
the pointer. Now we have the first if statement in black. If student marks is greater than 40 then execute. Now within
the then clause within the then statements of the first if statement we've started another if statement. So
if student marks is greater than 40 then then this if statement will be executed.
Then if student marks is greater than or equal to 70 then output distinction otherwise else output pass.
Okay. So if student marks are greater than 40 the second if statement will come into play. And if the student marks are greater than 70 it will output distinction. If it's something like 50
distinction. If it's something like 50 it will out pass. Now and then end if the first if statement closes. The first
if statement is in the golden color.
Okay. and then it will output good job.
It's important to note that the good output good job statement is within the first if statement. Okay, the second if statement has ended. It is within the then statements of the first if
statement. And we then go on to the else
statement. And we then go on to the else clause of the first output statement and it will then output if student marks is
not greater than or equal to 40 it will output fail. Make sense? and then end.
output fail. Make sense? and then end.
And that's nested of statements. Okay. Case of statements.
statements. Okay. Case of statements.
Case of statements allow different statements of code. They allow one of several branches of code to be executed depending on the value of a variable.
Okay. Case of statements can be written with an otherwise clause and without an otherwise clause. This is shown in the
otherwise clause. This is shown in the examples here. First, we're going to do
examples here. First, we're going to do it without an otherwise clause. Let's
bring up the example. Okay. Example. Okay. So, this
example. Okay. Example. Okay. So, this
is a program that takes in a number as an input and then displays a message.
So, what a case statement does is that it checks to see if a case applies. For
example, when a case is applied, it the statements in front of that case are executed. So input number, we in take an
executed. So input number, we in take an input of a number and begin case of that number. Now if that number is one, the
number. Now if that number is one, the output will be lucky number one. If it's
two, the output will be cool number two.
If it's three, awesome number three, four, great number four. Now if none of these values if the num if the variable number does not store 1 2 3 or four and
another value it will output your number is invalid. So the otherwise the
is invalid. So the otherwise the statements of the otherwise clause are executed when none of the cases above it are applied and then you end the case of
statement with end case. That's it for case statements. I think we begin the
statements. I think we begin the question answer session after this. Yep.
Okay. Now we have concluded input output basic library routines operators and selection.
Okay. Um Okay.
I want to talk. I want to talk. I I feel I feel extroverted now not having to talk for so long. Does the condition have to be a number um in a case or can
it be boolean like a string?
Sorry, can you repeat it? I do not know what they meant. Does the condition have to be a number in a case or can it be
like a boolean or a string? In the case of statements, if that's what you're talking about, um the the variable can
be a string. Yeah. Yeah. It can be of any data type, right? Yeah. So it can be like case off name and then it would start with I don't know John, David,
Sarah. Then I'll put different greetings
Sarah. Then I'll put different greetings for them for example. Yep. Cuz the syllabus doesn't
example. Yep. Cuz the syllabus doesn't specify that case of only applies to integers. Okay. So it can be booleans,
integers. Okay. So it can be booleans, it can be strings, it can be chars in a substring. Yeah. So it's the
variable you're referencing, then the start index, then the length.
Yep.
Any other questions?
Any other questions, guys? That is allowed
guys? That is allowed um any single statement. So, you can do one one statement, but if you do multiple, you can't. So if you want to
put multiple statement um in the case of something then you would be using a procedure or a function instead
which you'll learn in a bit. Uh yeah and the syllabus specifies that you should only keep your case of statements to one line. If they exceed one line you should
line. If they exceed one line you should use if statements instead of that. So
you can go on to use nested ifs for that. Okay. Someone asked about
that. Okay. Someone asked about substring. So
substring. So um the start index is where where the part of the string you're trying to
extract starts. For this instance you're
extract starts. For this instance you're trying to get app and it starts with a.
A is the second um index second position. So that's the start index of
position. So that's the start index of two and the length is four. So it
becomes happy. Um I've heard what do you mean by indenting? So indenting
basically uh means you know um writing the code like putting a space before or a tab before writing the code or here
for example you're putting space before because it's in the case off section.
That's what indenting means.
Can you show the nested diffs again? Got
a look at it.
Someone wants to see the neester diffs again. Nester diffs. Okay. How do you
again. Nester diffs. Okay. How do you know when to indent? So if you're um if you're using some like fancy
control structures like if or case or in the future we're about to teach like for loops or while loops anything that
um is a fancy control structure then you indent inside. Will you lose marks? Um,
indent inside. Will you lose marks? Um,
in normal questions, I believe you don't. But regardless, you should just,
don't. But regardless, you should just, especially in the 15 markers, so the the examiner has an easier time marking for
you, even if it Yeah, actually. Yeah,
readability is one part of um the 15 marker.
Syntax definitely carries mocks. It's
specified in the marking scheme for it.
Any other questions? Okay. And uh there was a the for the uh what was it?
Indentation question. Uh when you're making well the what the syllabus wants you to do is when you're making a statement inside of a statement you
indent it by four spaces. Okay. And for
example, if you're using an if statement. And now the syllabus says
statement. And now the syllabus says that when you're using an if statement, you don't need to indent four spaces for the then clause. when you add the then clause, you indent two spaces because
the then clause is essentially an extension of the if statement. Uh the
same goes for when you're using nested ifs. If you're putting an if statement
ifs. If you're putting an if statement inside an if statement, you only leave two spaces, not four. But for example, if you have uh an if statement uh and
you're if and then and you're adding an output statement, if you're putting an output in there, then you need to indent the thing by four spaces. If say you're
using a case and and case of and then you're inputting the values, you leave a space of two, not four. Okay? Because
they are an extension of the initial statement. That's what the syllabus
statement. That's what the syllabus says.
Okay, puppy. Any other questions?
I have not seen.
Will we lose Mark if we use case?
No, it's a feature. You should use it.
Uh, and no, you don't have to number your lines. You once you get the exam
your lines. You once you get the exam paper, you're not supposed to number the lines. You're supposed to indent. You're
lines. You're supposed to indent. You're
supposed to comment.
It's just easier to write here. Uh, no,
show you guys like this.
Okay, puppy, there's a question and this is I think an important one. Can we
write the if statement like this? If
variable statement two space then essentially can I put the then clause right after in the same line as the if statement. I've seen this a lot in the
statement. I've seen this a lot in the channel as well. Yes, you can.
I prefer that actually. Yeah. Um, oh
yeah, cuz most of the languages do it that way, right? The Yeah, language. And
also, and one more thing question, sorry, continue. You don't have to
sorry, continue. You don't have to bother with the two space indentation or whatever with um with the then.
Yeah. And
uh Okay. Is there a terminating command term like end or do we have to use an explicit variable such as a found to terminate
the repeat until? You will have to use a variable. There is no break. There is no
variable. There is no break. There is no nothing to end it.
Yeah. Um what if there is no space for you to write the statement in one line?
So, uh, you just carry on the well, try to squeeze it if you can, but if not, carry on on the next line. And if it's an indented statement, then don't indent
the next line. You're carrying on because you're showing you're carrying on. You're not showing that you're
on. You're not showing that you're writing another statement. Do you comment with a slash
statement. Do you comment with a slash or hash slash?
[Music] Um, we will do passages at the end.
pseudo code you're supposed to use / slash. Okay, for if statements the
slash. Okay, for if statements the question that we get often is can you can we use else if in pseudo code? It
would be best if you don't use L-s because the because Cambridge has specified a certain syntax for pseudo code and since pseudo code carries marks and since syntax sorry since syntax
carries marks you should always use nested if statements instead of else if okay techni okay so why can't you so it's just it doesn't exist on the
syllabus and if you do um what you do is you put an a space between else and if and you add an extra end if at the end.
So, it's no different from just, you know, using an uh if or else.
Okay, I think that's it for now. Emit
continue. I'll answer in chat. Okay, so
now we're now going to start with iteration. Firstly, we're going to start
iteration. Firstly, we're going to start count controlled for loops. So, for
loops are four loops iterate a set number of times. Iteration basically
iterate means loop for loops loop a set number of time. Now for loops take an identifier of data type integer. So a
variable the variable that we use in this for example in our example we have for counter 1 to 10 output counter and the next counter. So in this example,
the variable counter will be assigned each integer value from 1 to 10 from value 1 to value 2. In our case, this is going to be each integer value from 1 to
10 until it reaches the value 10. So it
is going to increment every time.
Increment means increase.
Okay? So it's going to begin with one for counter 1 to 10. Output counter is going to output one. That's one
iteration complete. On the next iteration, it's going to be incremented.
It's going to be increased to two. It's
going then it's going to go ahead and output two. We're going to show a
output two. We're going to show a demonstration for this on pseudo code pro in a bit. Okay. So, basically now by
default in four loops the the variable is incremented by one. So 1 2 3 4. We
can use the step clause to set the increment. So if we use a step of two
increment. So if we use a step of two then we can increment the variable by two on every iteration. So one then three then five. We're going to demonstrate that on pseudo code pro in
just a second. Let's move on to the next example. For example, if we have a step
example. For example, if we have a step here four counter 1 to 100. Oh counter 1 to 100 step two. So
100. Oh counter 1 to 100 step two. So
this is going to go one then three then five. and it's going to output counter
five. and it's going to output counter at every iteration and after every iteration it's going to increment it by two. Now step clauses can also be
two. Now step clauses can also be negative. Now when step we use a
negative. Now when step we use a negative step clause then what we do is we make value one larger than value two.
So we iterate from a larger value to a lower value. Puppy can you pull up the
lower value. Puppy can you pull up the example for negative? Okay. So here you can see that
negative? Okay. So here you can see that in the first two examples our value one is smaller than our value two because we're incrementing we are increasing until we reach the value two which is
higher than the first value. When we add a negative increment a decrement essentially. So we have uh our value one
essentially. So we have uh our value one is greater than our value two because we're because we're decreasing the
identifier from value one to value two.
Okay, let's go to the demonstration and then it'll make more sense. Okay, first we're going to go
sense. Okay, first we're going to go without a step first. Declare counter.
Now when we run this after every iteration counter is going to be incremented by one and it's going to output numbers from 1 to 10. Okay. Now
what we're going to set a step of one puppy. So by default
puppy. So by default uh the step of a for loop is one. So if
we set the step to one you'll see that there is no change in the output.
However, if we change the step to two, let's change the step to two. Okay. So now it's going to
two. Okay. So now it's going to increment counter by two on every iteration. So it's going to output one.
iteration. So it's going to output one.
Then it's 1 + 2 3 3 + 2 5 5 + 2 7 and then 9. But when it reaches nine, okay,
then 9. But when it reaches nine, okay, what's very important is that if an iteration causes the value of
the identifier to cross the second value, the loop will terminate. Now this
might not make sense. I'll repeat. If an
iteration causes the value of identifier to pass value to the loop terminates.
You can see this as we have nine. Right?
Now the code would have iterated and when the code iterates with a step of 2, 9 + 2 would have been 11. This would
have given you 11. But our upper bound in this is 10 is the higher value which is value two. It's not it's higher. It's
sorry it's lower than 11. It's 10. So it
can't cross in. Hence that iteration never takes place and that increment never takes place. I hope that makes sense. Okay. Now let's move
sense. Okay. Now let's move to the next slide. Yeah, that's it for for loops.
slide. Yeah, that's it for for loops.
Okay, now we have postcond conditional repeat and preconditional while loops. So the repeat loop uh what repeat
loops. So the repeat loop uh what repeat loop does is that repeat the conditions inside a repeat loop will be executed at least once. So repeat loop check the
least once. So repeat loop check the repeat loop contains a condition at the end. After every iteration of the repeat
end. After every iteration of the repeat loop, the repeat loop checks to see if a certain condition is fulfilled. Now if
that condition is fulfilled, the repeat loop will terminate. However, if it's not fulfilled, if the condition evaluates to the boolean value of false,
it will keep iterating until it evaluates to the boolean value of true.
Okay. So what we're going to do is see an example. Now this starts a repeat
an example. Now this starts a repeat loop. Repeat loop starts output enter
loop. Repeat loop starts output enter the password and it will prompt a user to enter the password. Now the password will be one. Now the password in our
case is 1 2 3 4 5. Now until the user enter password equals to 1 2 3 4 5 the repeat loop will keep looping.
Okay. Now I hope that makes sense. Going
over to while loops now the while loop is a preconditional loop. The condition
in a while loop is tested before the statements are executed. And the
statements will only be executed if the condition evaluates to true. Okay. For
example, while condition while condition is true do statements. So the statements are only going to execute when the when
the condition evaluates to the boolean value of true.
Um okay. So the loop we the loop might never iterate. So if we start the loop
never iterate. So if we start the loop if the control is given to the while loop and the condition is not evaluated to false to true and it's false. This
loop will never be executed. At every
iteration after the statements are output. What the loop does is it checks
output. What the loop does is it checks to see if the value if the value is remains true. The second the value
remains true. The second the value becomes false this it terminates. Now in
the example here we have output enter the password. It prompts a user to enter
the password. It prompts a user to enter the password. So while password does not
the password. So while password does not equal to 1 2 3 4 5 output incorrect password and in and prompt the user to enter the password again. So, it's going
to input, it's going to prompt the user to input the password again and again and again until it's 1 2 3 4 5. Okay, let's move on to the next
5. Okay, let's move on to the next slide. Now, we're going to start with
slide. Now, we're going to start with sub routines. Firstly, we're going to do
sub routines. Firstly, we're going to do procedures, then we're going to move on to functions. So essentially a procedure
to functions. So essentially a procedure is a set of programming statements that are grouped together that can be called to perform a certain task at any point in the program. Okay, please go slow
here. Okay, I'll explain this in detail
here. Okay, I'll explain this in detail since a lot of people don't understand that. So we use sub routines when our
that. So we use sub routines when our program has certain tasks that are repetitive. So if for example our
repetitive. So if for example our program needs to print and for example our pro procedure needs to output the
menu again and again and again instead of typing out the meat beef pork vegetables carrot lettuce again and again and again. We can
just define the procedure the sub routine at the start of the code and then we can call it anytime inside of
the code. So what it essentially does is
the code. So what it essentially does is that it allows us to do repetitive to call repetitive tasks easily. Then now
this is how you define a procedure. You
use a procedure command. You give the procedure a certain identifier and then you input the statements that are going to be executed once the procedure is called. If you don't understand what
called. If you don't understand what being called means, we're going to explain that in one second. Okay. So
look at the example here. The procedure
is the identifier of the procedure here is print menu. And what this does is it outputs two output statements containing foods. Okay. And then we end procedure.
foods. Okay. And then we end procedure.
Okay. So when we call a procedure, we use the call keyword. Okay. Call
followed by the identifier. So here we output the string hello customer please look at our menu. And then we say call print menu. So this is going to output
print menu. So this is going to output the string hello customer please look at our menu. Then it's going to call the
our menu. Then it's going to call the print menu procedure and then the statements within that procedure are going to be executed sequentially. First
it it's going to output meat, beef and pork and then it's going to output vegetables, carrot and lettuce. Okay. So
this is how we this is how we uh use procedures without parameters.
Procedures can also be used with different parameters. One second. the
different parameters. One second. the
parameters entered in a um just to emphasize on the use case of procedures, right? Uh so for example, the customer
right? Uh so for example, the customer maybe you run into a new customer. So
you would use you would call print menu again. So you can print the menu again
again. So you can print the menu again or if the customer wants to reorder again um you can call print menu.
Yep.
So basically we streamline tasks that would have been repetitive. Excuse me
just one second. Apologies. Okay, I'm back. Okay,
second. Apologies. Okay, I'm back. Okay,
so this was an example of using procedures without parameters. We can
also use procedures with parameters.
Okay, let's move on. That's done.
Next, you can also give your parameters.
Now, we can use now we've seen one use case of this. Okay, now we're going to see a procedure with parameters.
Parameters, the parameters that we enter into a procedures will be used as variables in the statements of the procedure. For example, this is how you
procedure. For example, this is how you declare a procedure with parameters.
Firstly the procedure followed by its identifier then brackets then the uh identifier of the parameter and then the data type. Okay. So for example
data type. Okay. So for example procedure greeting first name is going to be string and the last name being input is also going to be string. It's
going to output once the procedure takes in these parameters it's going to use these parameters in its statements. So
it's going to output good morning mister and then it's going to output his last name. You can see the last name is the
name. You can see the last name is the same identifier as the parameter that we've entered. So and then we're going
we've entered. So and then we're going to go output could I call you first name. Same once again you'll see is
name. Same once again you'll see is going to be the same identifier as the as the uh parameter that we used for the first name. And then we do end
first name. And then we do end procedure. Calling a procedure with
procedure. Calling a procedure with parameters is is almost the same. You
use the call keyword and then you put the identifier. In this case, we
the identifier. In this case, we declared it as greeting and John Smith.
Okay? So, a string containing John, Smith. So, when this is called, it would
Smith. So, when this is called, it would output good morning Mr. Smith. Could I
call you John? That's
John? That's it. That's how you streamline repetitive
it. That's how you streamline repetitive tasks. Okay, moving on to functions.
tasks. Okay, moving on to functions.
Functions are just like procedures. They
function the same as procedures except they return a value to the main program to the point at which to the point at which they were called. Okay. So for
example, uh we define a function with parameters such as function identifier the data type one. So the we declare the first
one. So the we declare the first parameter with its data type and then the second with this data type. When
defining a function, we also use the returns keyword which tells us which data type is going to be returned to the point that it was called. Okay. So this
is how a function works. We have the GIF. Puppy, if you could pull up the
GIF. Puppy, if you could pull up the pointer. Okay. So we declare result as
pointer. Okay. So we declare result as an integer and then we start a function add two. We call the function add two.
add two. We call the function add two.
Now what this function essentially does is it takes an input of an integer and then it uses and then it adds two to that integer. So we are specifying that
that integer. So we are specifying that this function will return an integer value.
So we take the we take the result variable and we assign it the okay let's wait for the gif to loop back okay so
we'll start we call it with the value seven we add two to seven and store that value in result and then return result
we return 9 the output is 9 okay I hope that makes sense to [Music] everyone Let's wait for the GIF to loop
back and I'll explain this one more time just if somebody has understood. Okay,
so we add the number seven as a parameter. It adds two to the number
parameter. It adds two to the number seven. It stores it in the value result.
seven. It stores it in the value result.
It returns result which is 9 and it outputs 9. See to the point where the
outputs 9. See to the point where the function is called. Hope that makes sense. Let's
called. Hope that makes sense. Let's
move on. I think that's oh file handling remains on okay let's move on now moving on to file
handling so file handling uh so for file handling we have reading to and writing to a file so before reading to or writing reading from or
writing to a file we must open a file first this is done using the open file command in capital again with the file identifier so now we have two modes for file
one is for the first is the read and then the second is the right mode. Okay, sorry. Uh so we can either
mode. Okay, sorry. Uh so we can either have it for read or we can have it for write. So once we open a file, let's
write. So once we open a file, let's move on to the example here. Okay, so
this example what this does is it copies uh a string from file A and then it stores that string in file B. First we
declare data as a string. We open the file file a.txt for read. Okay, this is important. Notice how it says read. Then
important. Notice how it says read. Then
what we're going to do is we're going to read file file a.txt, data. So what this is going to do is it's going to read the contents of file A and it's going to
store its contents into the variable data. Okay. And then we're going to
data. Okay. And then we're going to close file A.XT using the close file command. So now the contents of file A
command. So now the contents of file A are stored in the variable data. Now to
write it to file B, we're going to open file B dot txt. Open file for write write mode. Okay. And then we're going
write mode. Okay. And then we're going to use we're going to use the write file command for file B txt. Write file.
Fileb.txt data. That means the contents of the variable data are now going to be written to file B. And then we're going to close file B. So now we have copied
the data from file A over to file B. Okay, that's it.
B. Okay, that's it.
That's my part done. We're done with chapter 8, pseudo code.
Um, so first, uh, why would you use parameters instead of just directly hard coding it in?
So for example in the greeting you might want to greet two different persons. So
you might want to call greeting once on John Smith and then call greeting David Blaine. So then now it will it will be
Blaine. So then now it will it will be good morning Mr. Blaine. Can could I call you David? So
um you know it's uh the the procedure is flexible to whatever you input in and I've seen another question
[Music] somewhere local variables can't be changed outside of the function right yes
um so the there is this concept of local and global variables so if If you um declare or assign a value normally
then then it it can be used throughout the program if it's in the main program.
But if you assign a value within the function then the value can't be used outside in the main program. For
example, um this result here, the result variable, it has became nine. But that
nine that result um variable if like you can't reference it. You can't do output result below here. It it just won't understand um what result is because
result only got assigned within the function. It's a local variable rather
function. It's a local variable rather than global.
Do we understand? Return and call. Yeah,
understand? Return and call. Yeah,
there's specific to each type. So in in procedures you're you're calling because you're not returning to a function. So
you're just calling the set of instructions inside. Whereas in
instructions inside. Whereas in functions um now you actually have to use it use the value. So you either output the
the value. So you either output the value you assign the value somewhere or do something with the value.
So now for example you could also say um like
answer is add two of seven. So now this answer can actually
seven. So now this answer can actually be reused somewhere rather than output
result that does not work because the result got assigned within the function.
So it didn't get return. Well, it got returned out to the output statement, but the variable result itself is still in um the function. So you can't do output
result because it won't know what value result is because it only got assigned within. It's a local
within. It's a local variable. We have not gone through 15
variable. We have not gone through 15 records yet.
No. Can it be used in other? So yeah, it can't be used in other parts of the code as in the variables that got assigned or declared within the function. But if the
value is returned um for example you say answer is add to of seven. Now this answer variable can be
seven. Now this answer variable can be used anywhere because now it's declared outside. It's it's a global variable.
outside. It's it's a global variable.
Any other questions? What does return do? So
questions? What does return do? So
um return is for example you use you call the function add two of seven. Uh the result of this
seven. Uh the result of this function is is nine. The nine gets returned out. So the answer becomes nine. If
out. So the answer becomes nine. If
let's say we had a function of um whatever returns
integer and function and inside uh it said return 25
then I don't know uh potato this would just be 25 because it's the return statement.
Or let's say we're using the original function but instead of um return result we did
uh we did all the addition and all that but we said return 30 40
um then add two of seven would return 40 because we didn't res return the result. We returned 40. I
hope that clears things up. Does nine get outputed or does nine
up. Does nine get outputed or does nine get stored in the parameter? Um so
nine gets gets to be the result. is
assigned to result and then um result is result is returned. So the
nine is returned to the output. Declare is not deaf in Python.
output. Declare is not deaf in Python.
Um deaf in Python you might say is function. You don't really declare in
function. You don't really declare in Python. You just assign the value if
Python. You just assign the value if normal variables.
Okay, I will start on chapter nine. Oh no, back to chapter 7. So yeah,
nine. Oh no, back to chapter 7. So yeah,
we have finished the design part of chapter 7. Um the pseudo code part done.
chapter 7. Um the pseudo code part done.
Now we can really speed things up because pseudo code is the majority of the syllabus. Yep. So in the life cycle
the syllabus. Yep. So in the life cycle you would have coding and coding is development of the actual program in
real languages. So pseudo code pseudo
real languages. So pseudo code pseudo code is a fake language and normally they would just use um pseudo code just to plan. So regardless of what language
to plan. So regardless of what language you specialize in, you would understand this code because they're supposed to be like English-l like statements and they're mimicking real code.
um in testing. So purpose of test data is to check the program works and it rejects any invalid data etc.
By the way, for all the chapter 8 things that is is uh for for all the chapter 8 things that
is that has like M scheme keywords like for example what's the difference between global and local or whatever you think they might ask in chapter 8 you
can check in pup notes for the answer to like actual wording answers like max scheme answers.
So okay back to testing. For example,
the program takes um only accepts integers between 1 and 10. First you would test normal data
10. First you would test normal data like 2, 4 or 7 because it is in 2, four or 7. Uh it is in 1 and
or 7. Uh it is in 1 and 10. There's abnormal data where
10. There's abnormal data where uh it's data that's supposed to be rejected. For example, ABC 976
rejected. For example, ABC 976 uh like that.
extreme data. So whatever is at the edge of being accepted while still being accepted. Now there's boundary data.
accepted. Now there's boundary data.
So if you want to boundary test for accepted values, it would be zero and no it would be a 1 and
10. And if you want to test for it
10. And if you want to test for it rejected uh boundaries then it would be 0 and 11.
Yeah. Now that is coding and testing done in the life cycle onto standard methods of solution.
So standard messup solutions are basically standard sets of algorithm we use to solve problems for like for example you want
to search a value um you don't have to come up with how to search a value every single time people people have thought of the most
efficient way to do so before so you just replicate that method in your language quick definitions algorithm is
a sequence of instructions. Search is to search and sort is to sort. So the first one we have here is
sort. So the first one we have here is linear search. So for example, you have
linear search. So for example, you have a 1D array of numbers and you want to check or you want to search for the number 33. You would go
number 33. You would go along and check each one and boom, 33 is found here.
Uh disclaimer that one I did not make that one I found it from Google. Anyways
example code for so you would loop through uh let's say the the array r has 50
numbers.
So you would loop through the elements from 1 to 50.
And if the number you're trying to find is equal to the value or the element you're looping through, then you have found the number.
Hello. Today now, hello. Today I'll be Oh, okay. Bubble sort.
Oh, okay. Bubble sort.
Um, I will send you guys a link on YouTube if you can't hear the stream, but if you can then just watch the stream. Hello. Today I'll be explaining
stream. Hello. Today I'll be explaining the basics of bubble sword, the swap optimization, and the index pass optimization. So, first of all, what is
optimization. So, first of all, what is bubble sort?
B sort is a fundamental sorting algm that works by repeatedly stepping through a list, comparing adjacent elements, and swapping them if they are in the wrong order. And to make this
easier, let's use numbers from 1 to 5. So let's mix them up
5. So let's mix them up first.
Now what it does is it would flip the first two numbers and check if the current number is larger than the next number. If so,
it swaps. Now it moves on to here whether
swaps. Now it moves on to here whether this is greater than this and five is greater than two so it swaps. Greater than three it swaps and
swaps. Greater than three it swaps and five is also greater than one so it swaps again. Now this goes again three more
again. Now this goes again three more times. Four is greater than two so it
times. Four is greater than two so it swaps. Greater than three so it swaps.
swaps. Greater than three so it swaps.
greater than one so it swaps.
No, it checks. Two is greater than three, which is not true. So, it passes.
Three is greater than one. Yes. So, it
swaps. 3 is greater than four. No. Four
is greater than five. No.
So, then it checks. Two is greater than one. Yes. So, it
one. Yes. So, it
swaps. Two is smaller than three, so it doesn't swap. Three is smaller than
doesn't swap. Three is smaller than four, so it doesn't swap. And four is smaller than five, so it doesn't [Music] swap. Now the list has been fully
swap. Now the list has been fully sorted. And now let's explain why for
sorted. And now let's explain why for the outer and inner loop, we have to go from 1 to 5 - 1. For the outer
1. For the outer loop, the worst case scenario is when 1 or the smallest number is at the
end. This is because the algorithm
end. This is because the algorithm favors the highest number and so higher numbers will be bubbled to the end while
the lowest number would just get displaced to the left. And so the worst case scenario is
left. And so the worst case scenario is when the lowest value is at the end and it has to be swapped 1 2 3 four times.
And so that is why the outer loop goes from one to four and the inner loop goes from also from one to four
because this the first index and it compares with the next second third and fourth and fourth compares with the
fifth and so if it's one to five then it would also compare fifth to the sixth but there's no sixth so an error would
happen. So that's why we go from one to
happen. So that's why we go from one to four and four would compare to five. So now let's explain the swap
five. So now let's explain the swap optimization. This is where we sort the
optimization. This is where we sort the list here. Again five is greater than
list here. Again five is greater than everything. Then three is smaller, four
everything. Then three is smaller, four is bigger, four is also bigger than one.
And then three bigger than two one. Two
is greater than one. And
one. And so even if we might have not done four outer iterations or in this case we might have but it would go through a
loop. It would go through an outer
loop. It would go through an outer iteration again until no swaps has happened. This is
because when there is a swapped that happened, it's the case when a number is greater
than the next. So if each number is smaller than the next, no swap can happen because they are already in ascending order. So that's why no when
ascending order. So that's why no when no swaps happen, the list has been fully sorted and we can end the loop.
[Music] And let's go to the index path optimization. This is
optimization. This is where again I said that the bubble sort algorithm favors the largest
number. So let's say on the first outer
number. So let's say on the first outer iteration four is smaller than five, five is greater than two and five is greater than one. So notice how the
largest number always goes to goes to the end. So after the first
the end. So after the first iteration, we can know for sure that the largest number is at the end because regardless it would be bubbled up and
swapped to the end. And so now we know that the largest number is already at the end. So we can only check so we can
the end. So we can only check so we can just check these four numbers instead of checking all five since we don't we already know this is in the correct
place. So we can just only sort this
place. So we can just only sort this instead. And so
instead. And so now four would be swapped. Four is
greater than one. So it would swap with one. And four is greater than three. So
one. And four is greater than three. So
it swaps with three. And notice how the second highest value is now at the second last place of the list after the
second iteration.
And same for if we check here one and so we can uh only check this after the third but this is already
sorted. The point here is
sorted. The point here is after after x index has passed we can ignore x as much elements
because the largest value would have already went to the end.
[Music] Okay, that is it for the bubble sword video.
Um, now I'll wait for those who went to YouTube because they can't hear the the stream volume. But yeah, does anyone
stream volume. But yeah, does anyone have any questions about
the bubble sort? Also, if you want to like actually see the code, um, you can check the notes, the pub notes in the
embed. Why are you so cool? Thank
embed. Why are you so cool? Thank
you. Pupnotes are in the the bot that keeps messaging or you can type pupnotes in bot spam.
Okay, we'll move on for counting, totaling, and finding an average. That's also considered a
an average. That's also considered a standard method of solution.
So um by counting you uh they mean counting how many iterations have passed in the loop. In totaling you're summing
values when you input numbers for example and finding an average is basically finding a mean. Um although
average I know I mean is a type of average but you're in CS you're not in math so an average is mean. Anyways
um this program oh we'll be going to pseudo code pro so it's easier to explain everything. Uh wrong
everything. Uh wrong one. Oh no I lost my program.
one. Oh no I lost my program.
Okay, let's type it up. I can use pup notes. Hey, look at
up. I can use pup notes. Hey, look at this.
Okay. Yeah. The the whole premise of this program is to enter a number enter numbers and find an average and
total.
So for example, I enter five, I enter 9, I enter 14. Um, and let's stop by entering
enter 14. Um, and let's stop by entering minus one.
And can you like not bother with me right now? Thank
right now? Thank you. Um, it's still bothering me.
you. Um, it's still bothering me.
Please stop. Okay,
stop. Okay, we'll rerun the [Music] program. Five, 9, 14, and let's
program. Five, 9, 14, and let's stop. And so we have entered three
stop. And so we have entered three numbers um excluding the the minus one to quit.
our total 5 + 9 + 14 is indeed 28 and the average is 9.3 also um the reason why I set total to one is
because the last one will ruin the total because we're adding the number to the total and the minus one does count as a
number also I have set count to minus one because um because yeah this minus one will not count as a number. So rather than zero
we're doing minus one. And so we'll go line by line. We
one. And so we'll go line by line. We
initialize a total and count. We keep
repeating this output process and input process. We output asking them to enter
process. We output asking them to enter a number. then input the number minus
a number. then input the number minus one is a way to end end the inputting. So I I use the minus one
inputting. So I I use the minus one system is because for example the next time you might want to enter 10 numbers
instead of three. So yeah, count is minus one because instead of initializing count to zero, um we will have an extra number here
which doesn't technically count as minus one just to stop the program. So
yeah, count equals count + one to increase the count until number is equals to minus one. That's our stop flag.
Um our average of course is total count the mean and we output. That is how
output. That is how you count total and find an average. Next let's find the maximum and
average. Next let's find the maximum and minimum from an array.
So the way I like to do this is for example we have an array of
temperatures 1 to 50. I mean 50 50 days for example so 50 elements and declare the minimum and
maximum we'll set the minimum and maximum to be the first value in case it is and even if it isn't uh that value will be overridden later.
So now that we have already started at one, we'll be starting count at two. Oh,
the arrow's gone. I should fix that in pub notes, too. Um for 2 to 50. And
50. And if if the current temperature at the index count is bigger than the current
maximum, then it becomes the new maximum. And then if temperatures
maximum. And then if temperatures um at the index count, so the temperature we're looping on is less than the minimum we originally thought
we were uh having, then the new minimum would be the temperature at the index count and we'll continue looping through
count. And lastly, we'll output maximum
count. And lastly, we'll output maximum and minimum temperature.
Oh yeah, note that you could also do from four count arrow 1 to 50. Um, and
if you want to do that for maximum you have to say - 999 and for minimum you have to say 999. Uh, so it gets immediately
999. Uh, so it gets immediately overridden by um the maximum or the minimum but I just
like to start at one because you know it's it's a waste of time.
Okay, we have finished standard methods exclusion. Again, you I'll finally
exclusion. Again, you I'll finally answer uh questions at the end of the chapter. And now we're on to validation
chapter. And now we're on to validation and verification checks. With
checks. With validation is basically checking the input is proper for your program.
For example, you're asking for um a student's mark maybe as a percentage or maybe just a test that is
out of 100. And so
um you would expect the number to be zero and 100, right? So you can use a range check. You ask them to enter
range check. You ask them to enter student marks. You input it and then you
student marks. You input it and then you keep doing it until it satisfied the condition. This condition being the
condition. This condition being the marks is greater than zero and less than 100 aka it's between 0 and 100
100. Next there's the length check. So
100. Next there's the length check. So
if you want for example the password to be exactly eight characters then you keep entering the password until the
length of the password is eight.
Um, then we have to type check if we want to check the input is a specific data type. Although technically you're
data type. Although technically you're in the gray area here because you can't really determine a type of things for
Cambridge pseudo code.
Uh the only question they might ask here is by asking you to enter a whole number and if
um if it's not a whole number you can ask it ask to enter it again. The reason
this works is because for example um you do 2.4 for mod. M mod mod is
getting the remainder, right? Divisor
dividend um equals whatever. And so you're trying to get the remainder. If you're trying to divide
2.4 by one, the remainder would be 04. But if you divide a whole number by
04. But if you divide a whole number by one, let's say 10 divided by one, the remainder would be zero because it perfectly fits to 10.
That's why you can check if it's a whole number or not. Or if you want to count it an integer, you can I guess. Now let's continue with
guess. Now let's continue with validation. So you can check the
validation. So you can check the presence. Um enter your email address
presence. Um enter your email address and if the we enter until the email address is not blank. This sign being not equal
to the format check is where you're checking it to be a specific format like for example a serial number or code to
be begin with ABC. So please enter serial number and we'll take the three charact first characters and check if it's
ABC. Um this works because one is the
ABC. Um this works because one is the start index. So this is the first
start index. So this is the first character and you're using three um length three. So first, second and third.
Now the check digit um check digits is typically on barcodes and it's how you it's when you
calculate um all these front digits and then put it into some random algorithm or some calculation method and
you would get a check digit at the end three. So now when let's say a cashier,
three. So now when let's say a cashier, the accountant or whatever you call them, um they type in the book code or the barcode,
whatever. Uh assuming they can't scan it
whatever. Uh assuming they can't scan it cuz the barcode got damaged or whatever, they they enter all the code, we would
get the the first digits except the last one. So I'm doing minus one here. And
one. So I'm doing minus one here. And
we're calculating the check digit by some unknown function named calculate.
This the unknown function.
Um and we check whether uh the the last digit which the last digit would have
the position of the length of the string um of length one. So just one digit here is equal to the check digit we just
calculated. This code you don't need to
calculated. This code you don't need to know because there is no algorithm you're supposed to know for check digit.
So basically you're using all the first numbers to calculate a last number. So
then next time you reenter the the the whole code you can check whether the last numbers is the same. If the last number is the same that means there you
didn't mistype it. Now in
it. Now in verification you have to you want to ensure the data is copied uh correctly
from one source to another. For example
um for your brain to to the password entry uh place. So you can do a visual check
uh place. So you can do a visual check or double entry check. These are two types of verification.
The visual check is where you look at it. You tell the person to look at it
it. You tell the person to look at it and yeah that's a check. So you can press the I button for on the password for example or for the double entry check
you know when you typically go make a password it would ask you to enter the password again just so they know that you have entered the correct password
when you set it.
This would be the code for um visual entry, you know, outputting the password for them to check and type yes to
confirm or uh entering a password, entering another password, and checking if they're the same. So that's the double entry
same. So that's the double entry check. Now lastly, in chapter seven, we
check. Now lastly, in chapter seven, we have choice tables.
So um basically you have a flowchart or pseudo code given to you and you're trying to trace the values
throughout the program. This is my easy formula. So
program. This is my easy formula. So
initialize the variables then mostly they're loops. So write the
they're loops. So write the corresponding values etc. I'll go I'll go through it with you guys. So here complete the trace table
guys. So here complete the trace table for the input data. Normally I try to understand what
data. Normally I try to understand what the code is first. So let's see
um it initializes total of zero and then account of zero and then it wants us to input a value
then so I assume this is some totaling program or yeah I see here average so probably both totaling and averaging um if the value is zero it's going this
way that means it when you type zero it wants the program to calculate an average
and re output the total and the average or if it's not zero then we continue if it's minus one then it's a stop so as
you can see normally you stop when it's minus one and then if it's the regular value so it's not minus one you just total up the value and you increment the
count it would go over and So let's see let's say 25 25 is a normal no let's start with initialization right
so they started at zero here and zero here now um 25 as a value inputed so it'll be
here and the value is not zero so we're not doing all this fancy stuff it's not manified so we're continuing
And total would increase by the value and the count would increase by one. So total would increase by 25 and
one. So total would increase by 25 and count would be one. Next
one. Next 35. Sorry about my
35. Sorry about my handwriting. Um that's
handwriting. Um that's 60 and then it would be two. Next is three.
two. Next is three.
Sorry.
Oh and uh 63 and the count would be
three and zero. So, we're now averaging and totaling.
So zero average is now calculated 63 / 3 is 21 and you don't have calculators in
this exam. So
this exam. So um yeah good luck with that. Then total is
that. Then total is uh outputs the total and outputs the average. the
average. the output. No, it doesn't output the word
output. No, it doesn't output the word output. What am I
output. What am I doing? Oh,
doing? Oh, sorry.
[Music] Um, total is
63. Calculators are not allowed. Yes.
63. Calculators are not allowed. Yes.
um the average is 21. So you go on the next line here
21. So you go on the next line here because you're outputting again. And then
again. And then um you've seen you you guys have seen me do this so I won't continue with that.
But please remember um when you see minus one it stops. So
sometimes they give you extra values, but if if it stops the program, then you stop. They like to catch you on the
stop. They like to catch you on the minus one. I've seen minus one in so
minus one. I've seen minus one in so many flowcharts. So yeah, be careful
many flowcharts. So yeah, be careful with that. Um the answer, yep, the first part
that. Um the answer, yep, the first part we did correctly. Yeah, it ends at minus one. Careful with
one. Careful with that. Okay, we have finished chapters
that. Okay, we have finished chapters seven and eight. Any questions?
Um, one of the most asked questions was in the um, average totaling and counting pseudo code, why was count minus one?
They didn't seem to understand that part. So, if you could revisit that,
part. So, if you could revisit that, this one, right?
Yep. Okay.
So, [Music] um for example, we made count to zero. We start
at zero. That's that's supposed to be normal. Uh, let's say we add we want the
normal. Uh, let's say we add we want the number five, we want the number four, we want the number three. So now the total
would be 12 and the average would be four and then we want to quit. So we do minus one by quitting to
quit. Um total is 12, average is three.
quit. Um total is 12, average is three.
Good. But the problem is no average is not three. Average is four. The problem
not three. Average is four. The problem
is that it thinks that the amount of numbers we entered is four because it counted the minus one here.
So then that made the count now four. So
then 12 gets divided by four to be three rather than the numbers entered being three and the average actually being four because 12 the average of this
obviously is four, right? Because it's
the middle value.
Okay. Any other questions? Why did he add the first value? Yeah, that one in the second line.
So, are you asking why I'm only putting it on the second line rather than
first? Or are you asking why I'm totally
first? Or are you asking why I'm totally like 25 to 50? Why the second line? Okay. So,
50? Why the second line? Okay. So,
um questions typically have initialization like zero um and zero of total and count that's
outside the main loop. This is the main loop. We've been gone through like total
loop. We've been gone through like total and counting, right?
Um, and if you're initializing some values outside the main loop, then uh you do that on the first line, then
you do all the loop stuff on the second line or third or whatever.
Yep. Okay.
Isn't it better to use while loop for totaling and averaging? Did I not use a
averaging? Did I not use a while? Oh, I use a repeat. H either
while? Oh, I use a repeat. H either
works. I just like to do um a repeat especially when you have minus one because it's pretty clear like you're you're repeating until you get a
minus one, you know. Any other
know. Any other questions? Does repeat take one more
questions? Does repeat take one more step than a while? Um
so sometimes it does, sometimes it doesn't. The main takeaway is repeat
doesn't. The main takeaway is repeat checks for the value after the loop whereas while checks before. So that
means that repeat will uh guarantee if I can find
repeat.
Oh yeah.
Um see you're already repeating. you're
already doing the stuff. But while
loop checks here and then does the loop, that means if the first time they enter the
password up top here is already 1 2 3 4 5, then it won't go in the while loop because you're already testing the condition
here. Whereas here, you're doing
here. Whereas here, you're doing whatever first, then you're checking here.
Any other questions? I'll move on to chapter nine
questions? I'll move on to chapter nine then. Okay, chapter nine is all about
then. Okay, chapter nine is all about SQL.
So um first I'll introduce you to single table databases which is all you'll do for IGCC computer science
SQL and then um how you should suggest basic data types and what a primary key is and how
to suggest the suitable one.
So here is a single table database. It's
database. It's basically it's basically like a collection of data um in in a table in one table right
because single table and for example in this case we want to keep data of different customers. So their first name, their
customers. So their first name, their last name, their country. This the column
country. This the column um Cambridge likes to call it a field and the row is called a record. So
one record of data is Maria Kramer from Germany that has customer ID 1 and the field would be the field of first name would have you know these
different first names. A cell, a data item, a column value, um is just one
rectangle and a table is everything. Now, if we want to suggest
everything. Now, if we want to suggest suitable basic data types, first we'll have to see what data types are even available for us, right?
Um so the first data type that is available is what text and alpha numeric. These
are two different things. The text data type is a collection of characters.
Um so it can be English alphabet, it can be spaces, it can be emojis, whatever.
Alpha numeric on the other hand uh can be only letters and numbers not spaces not emojis not special characters. So that's the difference. So
characters. So that's the difference. So
keep that difference in mind because Cambridge likes to trick you a bit.
Um when they want you to suggest a suitable data type. Sometimes it's
interchangeable. A lot of the time it is. But just please know the difference.
is. But just please know the difference.
Text you can include the number. Text is
like a string. You can include anything in text. But alpha numeric only letters
in text. But alpha numeric only letters and numbers. A character is one single
numbers. A character is one single character in one in single quotes. Um a
b c whatever in lower or uppercase. It can also be special
uppercase. It can also be special characters. Now boolean can it's just
characters. Now boolean can it's just two valid states true or false. yes and no
or anything that has two valid states not just these two because it's SQL now rather than code. For example, in a past
paper, um there was an SQL table with horses and it included the gender with M and
F and you would call it boolean, not a character because it's not even true or false, but it's M or F. So, you know, to
validates rather than a character. Not that these are gender of
character. Not that these are gender of horses. I am not making any comments
horses. I am not making any comments whatsoever.
Um next we have integers which yeah integers whole numbers but also negative numbers zero
whatever real um any type of numbers including fractional or decimal or whatever date and time they're often
interchangeable for Cambridge IGCC um date being a date time being a time
and time hasn't come up often or at all I don't think in past papers but yeah minus 5 is a real it's a number
yeah an example for suggesting data types let's say we have a game store with different games
um game ID name and description okay I I'll have you guys suggest what Each field game ID name description should have
um as a data type. So, first game ID.
What do we think? Alpha numeric
think? Alpha numeric indeed. It could be tax, but Cambridge
indeed. It could be tax, but Cambridge would way prefer alpha numeric because um first, you know, you only need
letters and numbers. And second is so you know, you're not mistyping something like a space or whatever cuz spaces aren't even possible. And third is it
saves memory because you only need you need lower data to lower number of bits to
represent only letters and numbers rather than all characters and spaces and everything. Name. What do we think?
everything. Name. What do we think?
name text text string string text text so the answer is text there is no string in SQL keep that in mind there's only text in alpha
numeric and I won't waste your time you know description is also text because there are spaces definitely Okay,
now let's learn um what our primary key is.
So let's see the purpose, right? Let's
say we have a restaurant, a a taco shop.
There's three customers, John Gondo, Sarah Johnson, and John Davis.
Um, and when we're keeping the names, we're keeping their first name and the initial of their last name. John D,
Sarah J, and John D. Now,
D. Now, um let's say they they come up to you and ask how
much how how many tacos have John Davis eaten? right here. You won't even know
eaten? right here. You won't even know because there are two John D's. It could
be John D, John Davis or John Doe. So
that's why now we have what you call primary key typically is some sort of ID
like customer ID. Um 1 2 3. So now John Doe could be number one and John D could be number uh John Davis could be number three. So they would know what customer
three. So they would know what customer they are.
And yeah, this is the mark scheme description. Um, it uniquely identifies
description. Um, it uniquely identifies a record. So, you know, a customer
a record. So, you know, a customer whatever the case study is.
And the primary key would be different for each record. That's that's the main point of it.
read, understand and complete SQL scripts to query data. So querying is
data. So querying is searching searching in the database.
Let's say you have a table called dog books and you want to um get the name of
descriptions of the books.
So you would select name and description from all the dog books. The
table name being dog books. So you're
getting the name, the description, these two fields from the dog books and you would get these. You could also do select asterisk
these. You could also do select asterisk from do dog books and asterisk is a wild card and that means you want everything.
So you get book number, you get name, description, news, truck left, and you see why that might be useful
um in a bit. But yeah, now what if you only want new type of dog books? So the
golden retrievers and the chibatu um dog books are are new in stock or whatever. And what if you only want the
whatever. And what if you only want the new ones?
Well, you can use the wear clause and you can check whether it's new. This
would be the same as new equals true.
But since it's already a boolean, you can just write where new. That's the
same for if conditions in the in pseudo code by the way. But
yeah, and the result you would only get the name and description of new dog books. New is true. these two
books. New is true. these two
dots.
Now, how do we differentiate between Okay, that's a very solid point.
[Music] Um, you don't have like in um in in SQL or in in Cambridge, I mean
Cambridge IGCC. So, there's only equal.
Cambridge IGCC. So, there's only equal.
Anyways, the wearer clause. Let's
continue. What if you only want new books that are 200 in stock? So you want new and you want 200 less than 200 in
stock. So you would search new and less
stock. So you would search new and less than 200 in stock. Um just like pseudo code you can use and you can use not you can use
uh or and yeah it would only be golden retrievers because it's true and 192
whereas this book is new but not less than 200 stocks. Now you could also order your
stocks. Now you could also order your query. For
query. For example, oh sorry um you can get all the doc books name
and description and or ordered by the name. So originally it was Pomeranians
name. So originally it was Pomeranians golden retrievers and beagles. Now it
starts with beagles because it's a B then yeah etc. And
also you can order by multiple fields for example first name and last name of let's say a
customer customer table. And so in this case you would first go by the first name. Um so Adam would be first then the
name. Um so Adam would be first then the two John's then let's say descending last name.
um Smith because an S and then D because an the O is before an A, right? And so that is how you specify
right? And so that is how you specify whether it's ask or whether it's desk is yeah or ascending or descending is by labeling those
two. Now let's say you wanted to to know
two. Now let's say you wanted to to know how many books are left. You can sum the stock that are
left and you would get 810. How many types of books there are?
810. How many types of books there are?
You select and you count and inside the count you put an asterisk um from the table dog books where there are new. So basically, you're trying to
are new. So basically, you're trying to count how many types of new dog books there are, which there are two because it's just golden retrievers and
jibu. And
jibu. And um question you might want to ask is why the asterisk? Asterisk normally
the asterisk? Asterisk normally represent like all the fields.
But in this case, um, you would always use an asterisk because if you labeled a field, there's really no point because,
um, counting only a field just basically does the same thing but exclude values that are empty. But in IGCC there aren't
any empty values. So yeah, just always count asterisk. Also, um when you order by
asterisk. Also, um when you order by order by name for example, by default it's ascending. Just pointing that
it's ascending. Just pointing that out. Now we go on to the summary.
out. Now we go on to the summary.
So the select statement is to choose the fields or the sum or count function to display. The from clause is to choose
display. The from clause is to choose the table, but you only have one table because you're doing RGCC, so don't worry.
Um, the wearer clause is the condition.
Order by is to choose what field you're ordering by. and ascending or descending
ordering by. and ascending or descending sum and counts. That is it for chapter 9. Any
counts. That is it for chapter 9. Any
questions? If we write ordered by name would be ascending or descending. It
will be ascending. Ascending is
default. Any other questions?
There was a question can we and if so how uh set des desk or ASC in order of
numbers can we set descending or ascending in order of numbers what wait I'll send the message down Oh yeah, numbers. Yes. Yes. Yes.
Sorry. Let's say
um we we can order by the stock left for example. Um so stock left ascending
example. Um so stock left ascending would be 102 then 142 then 192 then 374. Has anyone written notes? Um, all
374. Has anyone written notes? Um, all
the notes you will need is in pup notes.
It that is being constantly sent by the bot. And yeah, it will be also recorded,
bot. And yeah, it will be also recorded, but just check notes because it will include some mark scheme descriptions especially in chapter 8.
presentation will be sent um in the computer science channel um pinned soon pop notes. Yes, there
pop notes. Yes, there is. Okay, let's go to chapter
is. Okay, let's go to chapter 10. So, first I'll have a bit of a tiny
10. So, first I'll have a bit of a tiny preface to chapter 10. Then I'll teach you guys the uh how to identify and use
the standard symbols for logic gates.
Then define and understand the functions of logic gates. Then um solving different
gates. Then um solving different scenarios.
So oh sorry.
So you might ask why even logic gates? Um the reason is in in the CPU or
gates? Um the reason is in in the CPU or in the computer you're storing you're storing whether it's a zero or one bit
um with these little transistors. And with these transistors
transistors. And with these transistors you can make a circuit that will add up to a very big circuit. And that means you can add stuff, multiply stuff and
then eventually run all these programs. Yeah. Now
Yeah. Now uh I will teach you the different types of logic gates and then we will combine it to a logic
circuit. The first type is the
circuit. The first type is the notgate. So it will just output the
notgate. So it will just output the opposite value. For example, um not zero
opposite value. For example, um not zero is one and not one is zero. So let's say this is called a truth table. Um
basically the values corresponding to each other. Our variable here is a 0 and one.
other. Our variable here is a 0 and one.
The result of not a would be one and zero because yeah they're the inverse for the and gate
um it would output one if both are one example a and b are one zero and zero no they're not um they're not both one so
the result is zero zero again zero again and one one so then it will become a Now types of logic gates we have the
orgate. So if either one is one either a
orgate. So if either one is one either a or b is one then x will be one. So you
can see here one one one one one. Um the
one. Um the norate if neither uh neither a nor b is one then x will be
one. So this will only be true when
one. So this will only be true when they're both zero. The nan gate
zero. The nan gate um if both aren't one
uh it it will be one which is essentially just not of a and b which basically means
um you know everything but when a and b are one it will be zero.
XR gate exclusively or so A or B but not both then it will be a one that's why it's called X or exclusively A or B but
not A and B so does it for logic gates now
um why so yeah they're used to there they are elements of a logic expression or a logic circuit giving one as output
and they're used to control data flow with like the AOU for example the arithmetic and logic unit you're trying to calculate things so you um make
circuits and do them and I'll show you a little demo of how they're used.
So let's say this is A, this is B, this is C. This is an ANDgate. This is a
is C. This is an ANDgate. This is a NOTgate and this is an OR gate. So
gate. So um since this is an O or gate uh either this part is true or this part
is true, the light bulb would turn on.
So this is the and gate. You need both for this to come on and this would be true or this not zero being one. So it
will already be true making it true or both. Um, I'll send the website here.
both. Um, I'll send the website here.
But yeah now for exam questions or scenarios um I'll introduce the most important
ones especially with logic expressions because if you know these these are called logic expressions, by the way, the the wordings. And so, if you know
how to do the words, then you'll likely know the equivalent drawing or um whatever of
it. They want us to draw this whole
it. They want us to draw this whole thing.
And what I normally like to do is I I focus on um the gates that are touching the
variables. For example,
variables. For example, um we start with not a so stuff that is directly impacting a rather than this and in the middle of
everything.
um or B and uh we'll skip that for now. B
exclusively or C [Music] um X or being the same thing but just with a line
across. And we combine these two
across. And we combine these two with an and. Yeah. And gates are just the flat
and. Yeah. And gates are just the flat version of or. Boom. We draw the logic
or. Boom. We draw the logic circuit. Yes, you can curve the
circuit. Yes, you can curve the lines. Technically, it's a bit better,
lines. Technically, it's a bit better, but as long as the examiner can read, they don't mind.
Now yeah we got it correctly and here are the labels.
So split it um into two parts and here and then we combine it and then yeah the result is
here and um let's complete the truth table. So
uh sorry we have oh the logic expression here [Music]
um not so what I like to do the easy formula TM um is break them into different columns then combine it. For
example, we want the first part and we do that by um first figuring out not A.
So no I mean sorry um by not A or B. No yeah yeah no not A.
So we break them into this and each different parts. Um, not a being one
different parts. Um, not a being one one 0 0 0 or
B. So, let's call this D for now. And
B. So, let's call this D for now. And
then D or B because we're combining not A with or B.
Um, and so if it's an or then if this is true, then this would also be true. and
also or B. So B is true in these last two and yeah neither. Now we want B, X or
neither. Now we want B, X or C. And
C. And so either but exclusively either not both. So Yep. Yep. This is both. So you
both. So Yep. Yep. This is both. So you
can't um here you can you can one here you can one one you can't and then let's call that
[Music] um F and let's call that E and this would be everything combined.
So E and F and so it would be something
like sorry um E and F. So it would
be zero. Um this is an and so one
be zero. Um this is an and so one one 0 0 both ones. So one because it's and
zero. Yeah, we got
zero. Yeah, we got it.
Um then a logic expression from the circuit.
So let's start from the first first inputs from the left then to the right. So
right. So um I will note it here because it's easier. X equals not a because we have a
easier. X equals not a because we have a not get here and then not a and
b and then this too far. So let's go back to here. Um we also have not
C and between these we're oring it. So
or so this would be the final answer and yeah this should be the last one and then we can go to
papers. So
papers. So um how do we find the logic expression from the truth table? We can do
that. Oh sorry
that. Oh sorry [Music] um by checking the rows that make it
true because yeah because that's that's the final answer. That's the result. We want
final answer. That's the result. We want
to see what made it true from these three and they don't want they don't want us to simplify at all. So the first
way that would make it true is by a and sorry I'll just type it.
The first way here would be A and not B and not C. The second way at the bottom
is A and B and C because they're all true. And so it's either either this way
true. And so it's either either this way or this way. You know what we can do? We
can put an or in the middle of everything. So
everything. So now it would be something like this.
You might think it's a bit long, but um they explicitly told us not to simplify.
So yeah, that is the final answer according to the mark scheme. And that is it for chapter 10.
scheme. And that is it for chapter 10.
I remember seeing a question. In the
question, if I wanted a line to go from A to C, would it intersect B or do I make it behind? I do not know what you understand by this
question. Do we have any other
question. Do we have any other questions? Thank you so
questions? Thank you so much. Um, it's not the end by the way.
much. Um, it's not the end by the way.
We have a test paper of paper two coming on. X nor is not in the syllabus so you
on. X nor is not in the syllabus so you cannot use it. We only rewrite and on that last
it. We only rewrite and on that last topic. What do you
topic. What do you mean? If two lines
mean? If two lines intersect then you make the intersection clear. Okay. Okay. Well, we don't have
clear. Okay. Okay. Well, we don't have any um for example just show you with the circuit I
guess.
Um let's say this didn't exist and um how do I get rid of this? Okay. And then this became this
this? Okay. And then this became this and this had no this is a knot.
Sorry.
Um and yeah, so just just cross the lines. It it as long as um the examiners
lines. It it as long as um the examiners can tell which lines go where and you're making the intersection clear, then that's fine.
Do we have to form the logic is from only truth table? Well, let's check this wonderful
table? Well, let's check this wonderful note section, shall we? Do we have to form a logic circuit
we? Do we have to form a logic circuit from truth table? Logic is to find a logic from a truth table. Yes, you do.
Um, in the notes I only included mostly for logic expressions because there would be like 10 or nine of these. But
yeah you do. How convenient
do. How convenient indeed. Couldn't it also be A or B or C?
indeed. Couldn't it also be A or B or C?
What do you mean?
Um anyways uh please clarify on that question but I got another separate point is for this question um you have to leave it like this. There
is no other way to do this. just find
the rows that will end up in a one and just or them. That's the only way. If
you somehow find an easier method or whatever, um you you'll get cut you get marks cut off you because that's not the way they
intended to. So yeah, and they said do
intended to. So yeah, and they said do not simplify. So they want you to find
not simplify. So they want you to find the combinations. Bobby, you'll never be
the combinations. Bobby, you'll never be asked to simplify an expression, right?
Yes, you will not be and you shouldn't at all. You should see the rose and what
at all. You should see the rose and what makes it true. Never seen it. Yeah.
So never simplified even if you know how.
Any other questions? Okay, let's do papers then.
questions? Okay, let's do papers then.
Yay.
That was a while. Papers, papers,
while. Papers, papers, papers.
Okay.
Verification is used to make you lot.
Yeah. Um is used to make sure a value is entered has not changed during the input.
While validation is checking is suitable for the program.
Um the type of validation. Okay.
So a type of validation would be a length check. They want in this
check. They want in this style. So what would be the validation
style. So what would be the validation check? this case it would be um the
check? this case it would be um the format check because we're checking it's in the date, month, and year style. And
style. And um would type check be correct? No, it
would not because they went to certain style and you can't do that by just checking it's a string.
one example of normal test data and the reason. So,
reason. So, um let's say 01 uh 1100 because that's a normal
date or something like this.
[Music] um abnormal. So
abnormal. So uh 1st of January 2000 that is not
accepted because that is not in the proper style.
Don't the reason seem a bit too vague? Um, well, let's see the
vague? Um, well, let's see the mask. A, that was correct. Format check.
mask. A, that was correct. Format check.
Yep.
Look, the only thing they care about is the the they should be accepted. You can add whatever, but
accepted. You can add whatever, but yeah. And
yeah. And rejected. So yeah. Um mention the word
rejected. So yeah. Um mention the word accepted or rejected. Describe how a length
rejected. Describe how a length uh how a length check could be used with the data entered.
So a length check could be used by checking
the date entered is 1 2 3 4 5 6 7 8 9 10 10
characters long because if they're matching this format then that means you know they included the the two date
digits, the two months digits, the four year digits, and um the two slashes.
Now, how should we make it two marks? Well, let's
marks? Well, let's see. Oh, yeah.
see. Oh, yeah.
um projected if too short too long because it's not in the valid
style. Can the space also be counted?
style. Can the space also be counted?
Yes, space is included in the length check. The length check just checks the
check. The length check just checks the number of characters. Okay, this is fun.
characters. Okay, this is fun.
draw a pseudo code statement that would um to the most appropriate pseudo code use. So let's say counting which one
use. So let's say counting which one would count. This one would definitely count
count. This one would definitely count because we're incrementing by one each time.
finding an average I mean pretty clear we're summing up and then dividing that's a mean and then totaling
um we're not toting anywhere these this is five not all pseudo code uses will be required using a conditional statement
that and then using a procedure that [Music] um and both here and in logic circuit
questions you guys have to make sure that the intersections are clear because let's say like this and let's say
totaling was I don't know intersecting that either like um just you know be be
good give the examiner a break let them fast. Okay.
fast. Okay.
Now they want us to find the minimum temperature from 25 elements. Let's
see.
So the temperature is already declared.
They already have values in it. So we
don't need to do anything.
[Music] Um let's declare the minimum being an
integer and uh let's also declare the count because we'll be looping soon I hope.
Um yes I do not need to declare the array but I do have to declare the rest or assume sometimes sometimes there are mocks for declaring sometimes there
aren't I don't know minimum like my favorite styles I like to do same thing as the first one then starting as the second because if the
second one is slower then it gets overridden anyways.
Um for count from 2 to 100 because we have 100 no we have 25 elements sorry and we will
uh check if the temperature is at the count is less than the minimum or the current minimum we know of
then That's the new minimum because that's actually lower. And if
lower. And if uh next count and then output the minimum
is this minimum. I hope
minimum. I hope um yeah indeed. See how most people will set it
indeed. See how most people will set it to a randomly high value so then it gets compared and then the first one becomes lower. But this is also accepted because
lower. But this is also accepted because you're being more efficient here.
[Music] um different cities.
So what does it want to do? Find errors
and suggest corrections. Okay, let's go
corrections. Okay, let's go through city does not have a colon here.
[Music] Um that's weird. Although there's already a
weird. Although there's already a boolean, so yeah.
So, although I don't know whether not being a colon here is me downloading it wrong or Yeah. something. When you're done,
or Yeah. something. When you're done, can I send? Yes, I
can. Um, yeah. No. Colon. Maybe. Maybe
not. I don't know how I downloaded it.
And then also um boolean type because glancing through here it's already clear that the name of the city
or the country whatever is going to be a string because it's the it's a name. Um okay. Now let's go back to
name. Um okay. Now let's go back to actually understanding the code.
So we're counting. So, it seems like we're looping through something.
Um, line number. You don't need to write any line numbers. Oh, that line number.
I mean, you can Yeah, you should probably um This is very rough. Type declaration
for city array line 01. Yeah.
01. Yeah.
to label the line number. Thank
you. And so the correction would be something like
this of string. Oh yeah. What what does the program do? The program seems like we're looping. So this is definitely
we're looping. So this is definitely wrong.
Um, oh, here it already tells us, sorry, allows the name of 50 cities and the countries to be entered and then it's outputed. Okay,
that's cool. Oh, yeah, we're doing some kind of
cool. Oh, yeah, we're doing some kind of loop here, there's until, so this has to be repeat and then um since city is being entered first,
this should probably be one and then two.
For reference, I assume what is going on here is there's a 2D array with city and
country. And so you'd have the name, the
country. And so you'd have the name, the country, the name, and the country, the name, and the country. So this would be 1, one. Um
country. So this would be 1, one. Um
this would be 2 one second row first column 3 one third row first column or one two
2 3 two for example and so both ending in two is wrong.
Yeah. Anyways back to how it was an if rather than um a repeat.
So if instead of repeat line uh 05 and
then repeat if to start a loop or whatever
error three so yeah I pointed out why is there a two rather than first? Because
city is supposed to be first.
Um two uh input city count two shouldn't be column two
line 07. Note that you should probably write
07. Note that you should probably write in better English than this. I'm just
you know going through the fashion [Music] um
declare no not declare input city count one this will be recorded and uploaded.
Yes. Um the last error count + one for out why is it looping from 1 to one? It
should be 1 to 50. So
yeah. And yeah, you can see here the city is definitely coming first because you're outputting like this.
And we have 50 city and countries.
[Music] Um, describe changes you would make to allow a city, a c the name of the
country to be input and to display um only the stored cities from that
country. Okay, let's see.
country. Okay, let's see.
So we want to first um oh we don't want to rewrite the
algorithm. Okay. So we want
algorithm. Okay. So we want to declare a variable for the in for the
chosen chosen country name as a string
then output out and in the country of choice.
Um then we want to implement uh linear
search. Wait,
search. Wait, no. Allow the name of an
no. Allow the name of an algorithm. Oh, the cities are actually
algorithm. Oh, the cities are actually stored.
Sorry. Okay.
So remove input of city name and the output prompt.
[Music] Um add [Music] uh uh change from repeat
until no [Music] uh change from until until 50
to first inputting um whether where the user wants to stop
entering the country name then until the flag is true or they want to stop
entering.
Um then implement linear search for the country
um to check. Okay. Well, now now the country
check. Okay. Well, now now the country names would also be already stored.
Yeah, we so yeah we are assuming the array has all the countries and all the cities stored and they want to enter the country name and we want to give them the city name back. Yeah, it's a bit
hard. Sorry.
hard. Sorry.
um input country name. They want to find rather than
name. They want to find rather than inputting to the array to the array.
um to check to find the country then
output the corresponding city with the same index slashc count slash row.
[Music] Um I think that is what they mean. Let's
see.
That's the fixed one. One, two, three,
one. One, two, three, four, five. Why are there
four, five. Why are there five? Oh, these are combined to two
five? Oh, these are combined to two marks. Okay, then I completely skipped
marks. Okay, then I completely skipped this.
Sorry. Um, it should either start at zero, uh, count should either start at zero.
So then it actually be, uh, becomes 50 instead of 49. Um, or until count is greater than 50. Now, yeah, country to be searched. Oh, please do label the
be searched. Oh, please do label the position. I forgot about that. Using a
position. I forgot about that. Using a
new variable. Yep. Um, add an if being searched. And if it is then
searched. And if it is then um I put the city cool variables and constants.
So consents should be consents should be assigned to a literal
whereas variables can be changed throughout the program which can't be changed
throughout the program.
Constants should be used for a specific value that will remain the same.
Eg mass constant like pi. variables
um should be used when calculating a new value or inputting value. Sorry if I do not have the
value. Sorry if I do not have the correct mark scheme wording. I am no longer the prime puppy.
Oh yeah, they should. They're both used for data
should. They're both used for data storage.
Programmers they should have meaningful identifiers.
Yes. And programmers should be able to understand. Yes.
understand. Yes.
Is it important to identify both variables are named data store?
Um I just say that they have meaningful identifiers. Yeah, same thing kind
identifiers. Yeah, same thing kind of flowchart. We're traceabling again.
of flowchart. We're traceabling again.
Let's go. I will screenshot this so it's
go. I will screenshot this so it's easier to see.
The question wording did not help. So,
let's see what's happening. Um, oh, it's the one we just
happening. Um, oh, it's the one we just did. Sorry. Well, you got the answer
did. Sorry. Well, you got the answer now.
Describe the purpose of the algorithm.
Um inputting uh multiple values until stopped with minus one. Then
minus one. Then uh I'll putting the total and putting the
average.
Sorry. Oh, I did not read. Okay.
Um, be careful of this as well. This zero actually goes back to
well. This zero actually goes back to the first rather than here. So, so
you're retoing everything when when there's a zero. And yeah, well, I get two marks
zero. And yeah, well, I get two marks calculating the average and outputting, but yeah, careful. Careful.
write pseudo code. Looks like we are doing some
code. Looks like we are doing some substring. Okay, let's
substring. Okay, let's see. So,
see. So, um it's explaining what substring is.
And now they want us to start a string the string in the quote. Let's do that.
Um in the quote variable string no
quote is learning never exhaust the mind. Yes it does. Anyways um let's
mind. Yes it does. Anyways um let's extract the mind.
[Music] So uh phrase is
substring of quote and frame the start index.
That's 1 2 3 4 5 6 7 8 9 10 11 12 13 14
15 16 17 18 19 20 21 22 23 24 25th. T is
25th. That's the start index. And then let's see the length. So
index. And then let's see the length. So
um 1 2 3 4 5 6 7 8 25 and 8.
Oh, and they want the lowerase version as well. So let's out key
as well. So let's out key that. And then let's output the
that. And then let's output the phrase.
Um yeah, you don't need to um assign the start index by the way or the
length. They they allow you to just use
length. They they allow you to just use it correctly. And yeah, use of substring
correctly. And yeah, use of substring use of L case.
Oh, they want you to display this too.
So, display the phrase first.
Sorry. Need to declare phrase. Indeed,
we do.
Okay. Now, why do we use procedures and parameters? So, procedures are used
parameters? So, procedures are used Um then we use sets of statements
or code throughout throughout the program.
This um means code gets repeated less often and
um is easier to read and more [Music] maintainable.
Any fixes to the set of code would also apply throughout the program.
Parameters are used to take in values from the main program
to the parameters. This means
uh the procedure can be reused with different parameter values. Let's
values. Let's see collection of programming statements. So yeah,
statements. So yeah, um keep that in mind. Allow modular
programs reused. Yep. Creation faster.
not really um make program shorter, less duplication of code. We said less repeating. So yeah, that's cool. That's
repeating. So yeah, that's cool. That's
easier to maintain to pass values from the main program. That is indeed
program. That is indeed um taking in values from the main program. That's what the parameter
program. That's what the parameter does. And like the function return gift
does. And like the function return gift I'm about to show you. Yeah.
And so that the so that it can be used and different data.
Yeah. Now they want us to draw the following logic expression. So
let's do that. Um let's draw it in paint actually
that. Um let's draw it in paint actually because that's a lot easier.
[Music] MS paint. I love
MS paint. I love it. A NAND
it. A NAND B. Good point is that NAND gates or NOR
B. Good point is that NAND gates or NOR gates just is nan but with the with the circle after.
Um, and then Bx or C. So, let's do that first with a cross here. Then we knot
here. Then we knot it. And
it. And then we or everything.
Um that is it for the bullying and complete the truth table.
So, let's use the um easy method. Let's do it here as
method. Let's do it here as well. Delete that
well. Delete that first. Um N and B
first. Um N and B That would be um and is 0001. So it would be 1 0 0 0.
That means only when uh no every everything except when both are one. But
are one. But yeah, no win both are one. And then
BXRC. Let's take this part and BXR C 0 one one one is not. So
zero um zero one one one is not and then we want to knot that
um so let's do everything opposite and we would like to or this part and this All right. So, one
right. So, one um one well everything that's one on the left is one then neither. So, zero and then
neither. So, zero and then one. That should be
one. That should be it.
Yep. Yep.
Okay. And yeah, that's what the working space is meant to be for.
Although, I mean, I suggest you don't do it in your head because just just don't. Okay.
don't. Okay.
This is why [Music] um I said to be careful of this because this is again a boolean not a
character. Number of records we
character. Number of records we have. Okay, I actually have to count.
have. Okay, I actually have to count.
1 2 3 4 5 6 7 8 9 10 11 12 um 15 18. Which field is most suitable for the
18. Which field is most suitable for the primary key? So of course the code would
primary key? So of course the code would be the primary key because the primary key is the identifier the unique one.
Records are row indeed and field is a column but you can easily remember by record row both
are reason is that code code is different for every
record meaning it can distinguish uniquely identify a row from all the other
rows. They like that word so much, you
rows. They like that word so much, you know, unique.
Um breed This can be easier, but I'll just say text just in case, especially with the possibility of
it being on another language. Yes, we
will do the 15 markers. So, hang on tight. Um,
tight. Um, generously because it's M or F age I assume is
integer.
Yep. And arrived is Date. Date
Date. Date time. String is
time. String is wrong. String is not does not exist in
wrong. String is not does not exist in SQL.
only text and alpha numeric remember real does exist.
Yes. But real real are numbers.
Um from what table we can go back to the question and see horses and I assume they want breed origin to be Scotland.
15 marker. Everybody, can we have a round of applause or something?
Thank you. Thank
you. Um, okay. Let's
go. I will I'll just put this on my left screen and then put pseudo code pro on my right screen.
Okay let's see. What does the question
see. What does the question want? Ping. Tenzo. I remember
want? Ping. Tenzo. I remember
Tenzo.
Okay. So, what flooring companies stores names of 100 customers in customers?
quotations shows the details of each customer's um quotation including each. So I
assume by that case the um the index of each row would be the same like the same customer to the same
details of each. The length is one decimal place. The width is one decimal
decimal place. The width is one decimal place. The area is to the whole number.
place. The area is to the whole number.
A choice is whole number. Um and price is whole
number. Um and price is whole number. Measurements are in meters. All
number. Measurements are in meters. All
floors are rectangle. Room measurements are between
rectangle. Room measurements are between 1.5 and five. So that's a range check validation. Remember guys?
validation. Remember guys?
Yeah. and customer in the index 4 um of customers. So yeah, as I said before
customers. So yeah, as I said before um the customer details of the force index was would be in the quotation of index
4 wood choices. These are the ones available and they're in wood type and price.
[Music] Um, they want to input a customer name, the room length and width. Check
that is valid. If not, re-enter until valid. Calculate the area. Input the
valid. Calculate the area. Input the
choice of the wood. Find the price per square meter
wood. Find the price per square meter that is here. So, we have to do a linear search.
Um and calculate or we can use a case off uh calculate the price of the wood needed because now we have the error of the of the room and the price per square
meter. We can just multiply
meter. We can just multiply it store the data in the relevant array and um output the
quotation continue and accept the next customer. This is why you read the whole
customer. This is why you read the whole question first.
um which is because uh you want to this this would be a loop on the whole program and you don't want to rewrite that do you and
since these are already stored values you don't have to declare them but then pseudo code pro very
handy they have this for you if I can find it somewhere
the exam questions. Yes, pass
papers. So you can check for 2023 October November to
[Music] two. No, wrong one. One second.
two. No, wrong one. One second.
[Music] Um, am I tripping? Okay.
tripping? Okay.
Here. Yeah. What's going here?
Okay. This is pseudo code pro.
and yeah. Okay, let's go back.
[Music] Um, so they want us to initialize with type and price that will be no. Okay, let's
be no. Okay, let's first um go through the approach I would take, right? So they want us to initialize. So
right? So they want us to initialize. So
that's definitely what you're going to do initially. And then
initially. And then um since we're going to keep accepting customers, I'll have to make a loop
first to keep accepting customers like a for loop, a while loop, repeat loop, something right?
And then I'll just do inputs. Then a
range check here. Then this means I'll have to use a repeat until um because we want until it's
valid. And then input the wood of
valid. And then input the wood of choice. Um so that's an input and then
choice. Um so that's an input and then that can be done with a case off or that can be done with a linear search preferably a linear
search because uh they gave us an index meaning and they made us make
uh lists uh arrays sorry. So yeah, they definitely want indexing and all that.
Calculate the price of wood needed that can be done by price per square meter and output. So yeah, that's how I would
and output. So yeah, that's how I would approach this question.
So let's declare wood type as an array of uh array as one two three of
um string the names are in string. So yeah
and then the price as a real because it's like this and then We initialize it
one is laminate in pseudo code pro. You could
do like bulk like this laminate and then whatever, but that is not allowed in the
real exams. So, I'll just stick to um what you would do in the exam. And then let's set the price
exam. And then let's set the price $29.99. And I'm just referencing the
$29.99. And I'm just referencing the view.
Now I want to repeat um and let's see if I have to initialize anything before. I don't think so.
before. I don't think so.
Okay, we'll see. Um we want their name and room length and room width.
So room room no other name. Input your
name. Enter.
Um, we can input customer [Music] name of string and
um, you see how I keep like declaring new stuff as I go along. So yeah, as someone pointed out in the chat, you should leave a very large gap at the
start. And so now you can declare stuff
start. And so now you can declare stuff as you go
output enter room length and we want to um keep doing that until it's valid.
So room length is to one decimal place.
So it's a real as a real and then yeah with I'll just say width and length area input
length until um and If the length is we said from 1.5 to 10
inclusive so less than 1.5 or length is um greater than 10. So
this is where it's wrong. Um we want to output an error message.
So invalid boom length would be between 1.5 and 10 inclusive.
Um and if until the length is greater than
equal to 1.5 or length is less than or equal to 10. No. And and
sorry. So now they have to be greater than 1.5 and 10. Uh less than 10. So
they're in between. Now we can do the same thing
between. Now we can do the same thing with the width.
Unfortunately, you do not have copy and paste in the exam. So you will have to type it all out.
And um we will calculate the room area by multiplying times
length. Simple enough.
length. Simple enough.
And then we will input the choice of wood and find
the price per square meter type of wood.
Input. Oh yeah. And in the 15 marker they they want marks for commenting. So
comment as you go along.
initialize types. Just simple stuff like this. even
types. Just simple stuff like this. even
if it's you think it's stupid.
Um, they give Max for it and you probably want Max would type um
uh wood and that's a string they want to enter.
No, we want to find the index. And
index. And [Music] um if they can't find the wood type,
then that mean that means um they entered it wrong. So they have to re-enter. So we'll have to make a
to re-enter. So we'll have to make a loop. and also
loop. and also um check whether it's found they found uh we found the
correct um wood type that they entered.
So we'll make a booty for one two let's say the length of wood type
just so that if we were to use this program in the future um it would be
flexible. Why am I declaring all the
flexible. Why am I declaring all the variables? So,
variables? So, um I I just like to do it. No, I I do it in this case because I'm using Pseudo Code Pro's
website.
Um and it it won't run if I don't declare. Anyways, you should
declare. Anyways, you should uh No, I mean, you can do it if you want. There was a serverwide argument
want. There was a serverwide argument which resulted in like two warnings or something, two timeouts.
Um, the way I like to do it is declare if it's not given. Some people don't declare it at
given. Some people don't declare it at all. Some people declare it
all. Some people declare it um declare everything. Although actually
I didn't identify anything because I use Python. But you shouldn't use Python.
Python. But you shouldn't use Python.
You should use pseudo code because the examiner would be used to marking pseudo code.
[Music] Um now you can let's
find whether the count is the same. So
wood type count is um the same as the wood entered. And if so, first we have to say
entered. And if so, first we have to say found is true.
Then also um also wood index. Yeah, we have to keep track which which one we found which position
actually which is an integer.
which would be the count we're going to. And no, next
to. And no, next count. And then
count. And then um linear search to find index of of wood.
press. Now, we want to do all this until until like they enter wood type that is actually found. This
found. This means we should repeat everything until it's found.
This also means we should uh declare it no we assign found as false post because
[Music] um we haven't no we want it to go into no yeah we want to check whether it's true or false here and the default
should be And we should probably throw in throw a message here saying um if not
found then output in not found what
type and if and this assumes we have found the wood type and kept track of the wood
index. Now we can find the price per
index. Now we can find the price per square meter of that wood price.
[Music] Um, well, yeah, it would just be price of wood type. No, wood
index. But I'll just use this whole thing when we're going to use it. Store data in relevant array. That's
it. Store data in relevant array. That's
where you do it.
[Music] Um, so in the quotations, oh, up to 100. Okay, that's
why 100 customers. But we'll have to use a wow because they might stop. Hey, will
they? No, they won't. Yeah, four. I'm
sorry.
Good. Good spot.
Um and then I'll add this to locationations of customer count.
And um one would be the length of the room
and two would be the width of the room.
Sorry. 3 would
be the area of the room.
Um, four would be the choice of the [Music]
room. No, choice of wood and X. Sorry.
room. No, choice of wood and X. Sorry.
So that's that. And then the price of wood required in dollars. So the price at wood would
index. Okay, we have
index. Okay, we have stored and now we have to output and everything and the price of wood
required. So let's have a total price
required. So let's have a total price here. They want to round in one dec
here. They want to round in one dec decimal place too. So, let's round that before that.
Um, do you need to have another flag for not found? I don't know what you mean.
Cuz if you found Yeah, it will run forever.
But we want them to give us a valid wood type. That's the whole point.
type. That's the whole point.
Well, price of wood required in dollars. That means um we have to
dollars. That means um we have to calculate the final price before do don't we? Okay. Total price. Total
don't we? Okay. Total price. Total
price is price of wood index times the area. Then we can store the total price
area. Then we can store the total price here. But we'll also have to
here. But we'll also have to round that.
And since for future reference, we also want to um round it for the output too, then we should probably round it here rather
than round on the store because we'll round it on the output anyways. Isn't your validation loop
anyways. Isn't your validation loop running forever then? Because found will never be true if it's not found.
Yeah, it it it it will run forever, but you know, we would expect the customer to actually like do it properly. Sorry. Um, so yeah, we got the
properly. Sorry. Um, so yeah, we got the total price in 2DP and now we want to output customer name.
customer name. I put
name. I put uh wood choice.
[Music] Um what what uh here we can comment again. Calculate
total price by uh by multiplying price and
area. Uh, put name, choice, wood choice,
area. Uh, put name, choice, wood choice, and price. And that should be it. Continue
price. And that should be it. Continue
to accept the next customer.
Um oh yeah, next customer account. And hopefully we didn't do
account. And hopefully we didn't do anything wrong. Let's
anything wrong. Let's see. Same name.
see. Same name.
Okay.
Um, I would have hoped that the length
um without proper casing work, but it would not.
Oh yeah, length does not work here. My
bad.
Three. Um, you can't find the length of an array. I will copy the code once it works and it should just
know quotations has not been declared. I thought pseudo code pro
declared. I thought pseudo code pro would do it for me. Let's not die
me. Let's not die here. Or I don't think I clicked it
here. Or I don't think I clicked it properly actually.
[Music] Um yeah, start the code. Um
code. Um Okay, they do not want to work. Oh,
because there's no sort of code. That's
why. Or at least I don't think so. Yeah, all the quotations and stuff.
so. Yeah, all the quotations and stuff.
It's just I'll do it myself then. No worries.
[Music] Um, declare customers as an array of 1 to 100
um of string. Then declare
quotations quotations with an array one to 100 of um no of real. Yeah.
One two five. There might be a type error. I
five. There might be a type error. I
would be so annoyed. Any tips on how to double check
annoyed. Any tips on how to double check your code?
Um, we'll first check if it probably um if it's proper. That
proper. That being Oh, why did pseudo code pro just capitalize everything I did. That's not
cool. Okay, whatever. Um, yeah, check check whether you commented. check all
the syntax first and then um go through the logic. I
mean yeah maybe before you write plan it out write it somewhere um in pencil comments are mandatory.
Yeah AO3 or something like that. Yeah plan it like with pencil just
that. Yeah plan it like with pencil just so you know the structure of the program.
Um, so then when you come back and read everything, it's it's cool enough.
Oops. Okay. Let's say the length is minus one. That shouldn't work. Okay,
minus one. That shouldn't work. Okay,
that's cool. Five.
Yep. Um,
10. Yep. And
then enter the type of wood. So, we have laminate, pine, and oak. Let's say
birch. That should be wrong. Okay.
Laminate wood choice.
Um, okay. Sorry.
And whoever I'm copying this code to, I'm sorry how um everything is full caps. But yeah, that should be it for
caps. But yeah, that should be it for that. Yeah, that's correct. Right. One
that. Yeah, that's correct. Right. One
second. Um 29.99
* 5 * 10, that's 50. Yay.
50. Yay.
Okay, that's how you do the 15 marker.
That concludes the session.
Do we have any other questions?
Let's take questions for like five minutes. It's It's been a while, right?
minutes. It's It's been a while, right?
Wake up, guys. It's done.
They do appear first.
Is that the last question? 25 marks,
guys. questions quick. Oh yeah, I'll send this in the chat.
No questions. The question says after Yeah, I just changed that.
Do we need to initialize every variable?
Um uh yes. I I don't know what you mean
yes. I I don't know what you mean though. There's there's some variables
though. There's there's some variables in the 15 marker that they tell you that this certain variables stores this certain value.
Yeah. Okay. So, you don't have to initialize those. If you have to
initialize those. If you have to initialize a certain variable, for example, uh the amount of football teams in a certain league. So, the question will ask you to
league. So, the question will ask you to input the number of leagues in the football in enter the number of teams in the football league. So, you will need to initialize that. It depends on the
question. Anything else? When is this
question. Anything else? When is this session going to be uploaded? That's a
big one.
Soon.
Um soon. It's It's pretty late for me.
So, either tonight within this hour or or tomorrow morning. That means you should probably subscribe to the channel.
Um, so so you can get updated whether the video is posted or not. Yeah. Yeah.
If he reaches 100 subscribers by tonight, he'll upload it by tomorrow.
Yeah. Yeah. Yeah. Just say that.
With the notification bell. Yeah.
Yep. Any other questions?
Pseudo code chapter 7 chapter eight um SQL boolean one question. Yep. Okay. Someone
has do we need to use for [Music] functions? Go on. Okay. for Python or
functions? Go on. Okay. for Python or pseudo code. Uh in the in paper two, you
pseudo code. Uh in the in paper two, you only have options to use a programming language for the 15 marker. For the rest of the smaller questions, you have to use pseudo code. So you'll have to learn
pseudo code in any case. And even for the 15 marker, most people say that um pseudo code is marked more leniently. So
you should go for that.
Yes, I support that even though I wrote Python, but you should write pseudo code. Um, unless you're like extremely
code. Um, unless you're like extremely skilled in Python and you're too too lazy to learn pseudo code or whatever, but you should already know pseudo code for the questions before. So, yeah,
you'll have to learn it anyways. Yeah,
for functions, the input taken, do we need to enter a number? Um, in in lower marks, most of the time you don't, but I do it anyways. But um you definitely
need to do it in the 15 marker just so the program is like fully proper um because they want proper proper program, proper variable names, proper
identifiers, proper everything in the 15 marker. How many data types are there in
marker. How many data types are there in SQL? Let's
SQL? Let's see. Let's see. Let's see. Let's see.
see. Let's see. Let's see. Let's see.
Let's see.
very beautiful slides I spent very long making.
[Music] Um yeah. Okay. So text alpha numeric
Um yeah. Okay. So text alpha numeric kind of similar characters boolean integer wheel
daytime no string. The string is basically why
string. The string is basically why aren't functions and procedures used for 15 markers? They are. You have to um you
15 markers? They are. You have to um you can and some questions require you to write them. For example, like the
write them. For example, like the specimen paper, there was the hospital monitor procedure.
Use it if you have to reuse some set of code multiple time. But normally if you don't then just don't bother. Yeah.
Yeah. But sometimes the question they explicitly ask you to write a procedure that does like Pokemon. Yeah. Yeah. Um
hospital one send right the slide. The slide.
So there's some animation that you know blocks is true. So that's why I will clean up the slide and then pin it in
the computer science channel.
So yeah, perfect. So the video, the slides, everything should be pinned in the computer science channel either today or tomorrow.
Um, okay. Whoever asked for
okay. Whoever asked for the Fine, I'll paste the pseudo code in here. Wait. In pseudo code, how would
here. Wait. In pseudo code, how would you put an output message for a function parameter? You don't put an output
parameter? You don't put an output message explicitly like I assume you mean to explain that this parameter does this. You you define the parameter
this. You you define the parameter yourself. So you know which parameter
yourself. So you know which parameter works.
Oh, like as you say input number one, input number for a sum function. No, you
when you're calling the function, you input those in the brackets.
Loading video analysis...