PuppNotes
PuppNotes
Ping me or add me if you are stuck or if anything is wrong with the context
Table of Contents
(You can access this via the outline sidebar as well)
Chapter 7:
● 7.1 Understand the program development life cycle, limited to: analysis, design,
coding and testing
● 7.2 (all 3 points are combined), it is in the design section of the PDLC
○ (a) Understand that every computer system is made up of sub-systems,
which are made up of further sub-systems
○ (b) Understand how a problem can be decomposed into its component
parts
○ (c) Use different methods to design and construct a solution to a problem
● 7.3 Explain the purpose of a given algorithm
● 7.4 Understand standard methods of solution
● 7.5
○ (a) Understand the need for validation checks to be made on input data
and the different types of validation check
○ (b) Understand the need for verification checks to be made on input data
and the different types of verification check
● 7.6 Suggest and apply suitable test data
● 7.7 Complete a trace table to document a dry-run of an algorithm
● 7.8 Identify errors in given algorithms and suggest ways of correcting these
errors
● 7.9 Write and amend algorithms for given problems or scenarios, using:
pseudocode, program code and flowcharts
Chapter 8:
● Disclaimer for chapter 8
● 8.1.1 Declare and use variables and constants
● 8.1.2 Understand and use the basic data types
● 8.1.3 Understand and use input and output
● 8.1.4
○ (a) Understand and use the concept of sequence
○ (b) Understand and use the concept of selection
○ (c) Understand and use the concept of iteration
○ (d) Understand and use the concepts of totalling and counting
○ (e) Understand and use the concept of string handling
○ (f) Understand and use arithmetic, logical and Boolean operators
● 8.1.5 Understand and use nested statements
● 8.1.6
○ (a) Understand what is meant by procedures, functions and parameters
○ (b) Define and use procedures and functions, with or without parameters
○ (c) Understand and use local and global variables
● 8.1.7 Understand and use library routines
● 8.2.1 Declare and use one-dimensional (1D) and two-dimensional (2D) arrays
● 8.2.2 Understand the use of arrays
● 8.2.3 Write values into and read values from an array using iteration
● 8.3.1 Understand the purpose of storing data in a file to be used by a program
● 8.3.2 Open, close and use a file for reading and writing
Chapter 9:
● 9.1 Define a single-table database from given data storage requirements
● 9.2 Suggest suitable basic data types
● 9.3 Understand the purpose of a primary key and identify a suitable primary key
for a given database table
● 9.4 Read, understand and complete structured query language (SQL) scripts to
query data stored in a single database table
Chapter 10:
● 10.1 Identify and use the standard symbols for logic gates
● 10.2 Define and understand the functions of the logic gates
● 10.3 (there are too many scenarios so I will take logic expressions since it is a
good middle ground for all)
○ (a) Use logic gates to create given logic circuits from a:
■ (i) problem statement
■ (ii) logic expression
■ (iii) truth table
○ (b) Complete a truth table from a:
■ (i) problem statement
■ (ii) logic expression
■ (iii) logic circuit
○ (c) Write a logic expression from a:
■ (i) problem statement
■ (ii) logic circuit
■ (iii) truth table
7.1
Analysis:
Abstraction – This is the process of getting to the key elements of the problems,
discarding unnecessary information that is not useful for you as a developer.
As you can see, we have simplified that chunky paragraph into important details to
work with as a programmer.
Decomposition:
● Definition: The process of breaking down the problem, which can be divided
again into smaller parts. This is done to make the problem easier to solve.
Design:
Structure Diagram – This directly shows the process of decomposition. It has a
hierarchical structure, from the top system to further subsystems.
Easy formula™
● Big system: just give the name of the overall system from the question
(improvise if not explicitly given)
● Sub system: typically either input, output, processes and storage; pick one of
those and apply a bit
● Further subsystems: name the actual method used to
input/output/process/store (if cie is mean, they might even subdivide further than
this so improvise)
Example:
[4]
There is no "perfect" way to make a structure diagram, so examiners are quite lenient
with this – the vagueness of this mark scheme shows it all:
● One mark for a hierarchical structure.
● One mark for suitable names for the sub-systems.
● One mark for identifiable inputs.
● One mark for identifiable outputs.
Flowchart – series of flowchart symbols connected by flowlines, forming a
step-by-step idea of an algorithm
Coding:
Development of actually used program, done in real programming languages
Testing:
Providing the code with different [combinations of] inputs to check if it's working
properly, then accepting and rejecting appropriate values. 7.6 Suggest and apply
suitable test data
7.3
Tips:
● Questions typically involve the standard methods of solutions
● Try to include key details because that's all the mark schemes care about (e.g.
bubble sorting in ascending order)
7.4
Code:
1 FOR Count ← 1 TO 50
2 IF Number = Arr[Count] THEN
3 OUTPUT "Number found"
4 ENDIF
5 NEXT Count
This programs starts with a for loop for length of array and uses count to change index
of array and compares it with number if it matches it outputs found
Bubble sort
Bubble sort is a sorting algorithm, whether for alphabetical order or numerical values.
This works by going through rounds of the array, seeing if one element is greater than
the next.
Explanation video by me :D
Bubble Sort (Optimisations) | 0478 IGCSE Computer Science
Disclaimer – code here uses Arr[1:5] for simplicity, while the other pieces of code
below uses Arr[1:50]
Version 1: Unoptimised
1 DECLARE Temp : INTEGER
2
3 FOR OuterCount ← 1 TO (50-1)
4 FOR Count ← 1 TO (50-1)
5 IF Arr[Count] > Arr[Count+1] THEN
6 Temp ← Arr[Count]
7 Arr[Count] ← Arr[Count+1]
8 Arr[Count+1] ← Temp
9 ENDIF
10 NEXT Count
11 NEXT OuterCount
Important notes:
● Outer loop: we are looping through the array, to go through swapping 49 times
● First 50-1 because, worst case possible, if 50th position has to go to the first
position, it will take 49 swaps
● Second 50-1 because we will be accessing the Count+1 index later, which 51
doesn't work, and 49 can already swap with 50
● Using Temp variable to swap between card n and n+1 because setting n+1 back
to n will just set n+1 to itself
Next versions are optimisations, increasing difficulty (although concepts should not be
too hard to grasp on)
Important notes:
● Instead of using an outer for loop and taking the disadvantage of looping 49
times to handle the worse case scenario, you can do the outer loop until there is
no Swaps left (the array has been sorted)
● IndexPassed is used to lower the amount of iterations in the inner loop
● This works because
○ with the nature of bubble sort, the highest value will be moved to the last
index by the end of the 1st pass, then the 2nd highest by the end of the 2nd
pass, and so on. This means we can ignore the last [IndexPassed]
values as it is already sorted.
Example – a program that takes in prices until stopped, outputting the total, numbers
count and average
1 DECLARE Price, Minimum, Maximum, Price, Count, Total : INTEGER
2 DECLARE Average: REAL
3
4 Total ← 0
5 Count ← 0
6 Maximum ← -99999
7 Minimum ← 99999
8
9 REPEAT
10 OUTPUT "Enter a price, (-1 to quit):"
11 INPUT Number
12 IF Number <> -1 THEN
13 Total ← Total + Number
14 Count ← Count + 1
15 IF Number > Maximum THEN
16 Maximum ← Number
17 ENDIF
18 IF Number < Minimum THEN
19 Minimum ← Number
20 ENDIF
21 ENDIF
22 UNTIL Number = -1
23
24 Average ← Total/Count
25 OUTPUT "Items entered: ", Count
26 OUTPUT "Total: ", Total
27 OUTPUT "Average: ", Average
28 OUTPUT "Cheapest item: ", Minimum
29 OUTPUT "Most expensive item: ", Maximum
Important notes:
● Declared the variables Total, Count, Average and Number
● Initialised Total to 1 as the last number remove one from the total (last
number is -1 which isn't legitimate)
● Initialised Count to to -1 as the last input is not legitimate
● REPEAT loop is used to keep on inputting numbers
● Total ← Total + Number this is totalling, adding up values to a total
variable
● Count ← Count + 1 this is counting, keeping track of the amount of iterations
● Average ← Total/Count this is averaging, finding a mean from a total
● Maximum ← -99999 – it may seem counterintuitive but we are checking
whether the current value in the list is greater than the maximum, to override it
as a new maximum – the first value would be set as the new maximum. Vice
versa for Minimum
7.5 (a)
Validation checks
Mark scheme description (Describe what is meant by data validation):
● Validation is an automated check carried out by a computer
● … to make sure the data entered is sensible/acceptable/reasonable
(I would also say suitable could also be in the last one)
Verification checks
Mark scheme description (Explain why verification checks are used
when data is input):
● To ensure that data has been accurately copied // to ensure that changes have
not been made to the values originally intended when data is copied
● … from one source to another
→ to put it simply, making sure no typo/mistake occurred
Examples are with the situation: program accepts integers between 1-10 inclusive
● Normal – data that the program should accept.
○ 2, 4, 8, etc.
● Abnormal – data that the program should not accept.
○ "ABC", 976, -4174
● Extreme – data that is at the edge of what is allowed
○ 1, 10
● Boundary – largest/smallest acceptable value and the corresponding
smallest/largest rejected value (i.e. testing the edge)
○ [0 AND 1], [10 AND 11]
7.7
Trace tables:
Quick definition (you don't need it):
A table to trace the value of variables, outputs and inputs. Each row cell identifies the
value columns (e.g. variable name, input('s variable name), OUTPUT).
Exam question:
Answer:
Easy formula™
● Most of the times you get 1 mark automatically for initialisation of variables (like
shown in the first row)
● They will mostly be loops, just write the corresponding values for each iteration
(this whole concept should be intuitive enough)
● The table will always have too much/extra space, so something might've gone
wrong if you used all
● -1 is usually a value that stops the algorithm, watch out for that
7.8
Tips:
● Identify syntax errors
● Values are also often wrong, so check that (e.g. for validation, comparison,
initialisation)
● Nonetheless, these are quite intuitive, it's not really a specification point that you
"revise" for
● Just learning pseudocode would be better
7.9
Answer:
● One mark for checking for < 0 or >= 0
● One mark for checking of both inputs
● One mark for correct repetition of both inputs e.g. use of REPEAT WHILE or
using existing loop, in separate loops or both in a single loop
For example:
1 REPEAT
2 OUTPUT "Enter cost price "
3 INPUT Cost
4 UNTIL Cost >= 0
5 REPEAT
6 OUTPUT "Enter selling price "
7 INPUT Sell
8 UNTIL Sell >= 0
This type of pseudocode question is the only common "amend" question. Other
questions can just be practised within the flowchart and programming topic.
Disclaimer for chapter 8
[3]
Mark scheme:
One mark for each point max three
● Variables / constants are used to store items of data
● The data stored in variables / constants are accessed by an identifier // named
data stores
● The value of a variable may change during the execution of a program
● The value of a constant will remain the same during the execution of a program
8.1.2
When seamlessly possible, use the simpler data type – integer instead of reals for
integers and char instead of string for single characters
8.1.3
Important note about inputs – in pseudocode, INPUT automatically converts the input
into the data type (e.g. INTEGER, CHAR) the variable is declared in. Whereas in most
real programming languages, the input function will return a string value.
8.1.4 (a)
Code:
1 DECLARE BookCode, LibraryID, BookID, CategoryID : STRING
2
3 OUTPUT "Enter book code"
4 INPUT BookCode
5 IF LENGTH(BookCode) = 9 THEN
6 BookCode ← UCASE(BookCode)
7 LibraryID ← SUBSTRING(BookCode, 1, 3)
8 BookID ← SUBSTRING(BookCode, 4, 4)
9 CategoryID ← SUBSTRING(BookCode, 8, 2)
10 // do more stuff here
11 ELSE
12 OUTPUT "Invalid book code"
13 ENDIF
+ - / * ^ MOD DIV
Add Subtract Divide Multiply Raise power Modulus Integer division
Logical operators:
● =, <, <=, >, >= and <>
○ Equals to, less than, greater than, less than or equal to, greater than or
equal to, not equals to
Boolean operators:
● AND, OR and NOT
○ NEVER use any other gates in programming – they typically do not exist
in languages
○ Covered in chapter 10
8.1.5
Important notes:
● If their age is 16 or above, they will get into the IF statement
○ If they are 18 or above, they will get into the second IF statement too
○ This is useful because if they are 16 or 17, it will say they are able to play
the lottery but they won't get the message of being able to vote
○ But if they are 18 or older, they will get both messages
● If their age is under 16, they will get sent into the ELSE statement being told
they can't really do much
8.1.6 (a)
Functions
● (If it helps, you can think of them like mathematical functions as they are very
similar)
● Same to procedures
● But CAN return – with the specified data type
● But also DOESN'T use a CALL statement
○ As the syllabus puts it – The keyword CALL should NOT be used when
calling a function. Functions should only be called as part of an
expression
Handy gif of how returns work (I made it :D)
(inspired by python discord's gif so access that if you want the python version)
Also look at how that parameter of 7 is passed into the function – that is how
parameters work. Note that any expression that can be evaluated (aka. calculated) into
the same data type can be put there too – i.e. you can put variables and stuff in there
too!
Exam question:
[4]
[6]
Mark scheme:
One mark for each technique
One mark for a matching description
Max six
● Use comments
○ to explain the purpose of each section of code
○ for example, logic / syntax
● Use meaningful identifier names to
○ clearly identify the purpose
○ of variables, constants, arrays, procedures etc
○ by example
● Use procedures and functions
○ to avoid repeated code
○ simplify logic
● Use indentation and white space …
○ to make the program readable
8.2.1
Now what if each student takes more than one subject? Well instead of making a 1D
array for each subject, we can use 2D arrays.
1 DECLARE StudentMarks : ARRAY[1:20, 1:10] OF INTEGER
2 FOR StudentNo ← 1 TO 20
3 FOR SubjectNo ← 1 TO 10
4 OUTPUT "Enter marks of student no. ", StudentNo
5 OUTPUT "For subject no. ", SubjectNo
6 INPUT StudentMarks[StudentNo, SubjectNo]
7 NEXT SubjectNo
8 NEXT StudentNo
Main points
● Arrays are used to store a collection of values, instead of making too many
variables
● 1D arrays store values one by one, for a limited length
● 2D arrays are more like a table/grid, having rows and columns of where values
can be inserted into
8.2.3
Reading values
You can reference the array by
● ArrayName[Index] for 1D
● ArrayName[Row, Column] for 2D
Treat it like a normal variable.
8.3.1
[2]
Answer:
One mark for each point (max two)
● Data is stored permanently
● Data can be moved to another computer
● Another copy of data can be made and stored//accessed elsewhere // backup
copy
To put it simply, you would want to store data in files because you want to keep the
data when you're done using the program and allow other software to access the files
(so then you can move it to another computer, make a backup, etc.).
8.3.2
Answer:
One mark per mark point, max five
● MP1 input a string into Saying
● MP2 correct use of OPENFILE to write data
● MP3 correct use of WRITEFILE to write Saying
● MP4 correct use of CLOSEFILE
● MP5 correct use of filename "Quotations.txt" throughout
Example:
1 OUTPUT "Enter the saying"
2 INPUT Saying
3 OPENFILE "Quotations.txt" FOR WRITE
4 WRITEFILE "Quotations.txt", Saying
5 CLOSEFILE "Quotations.txt"
● The file names doesn't have double quotes surrounding it, but then in the mark
scheme earlier, they used "Quotations.txt" with double quotes
● After contacting an examiner, they said WITH DOUBLE QUOTES is correct, and
the syllabus is wrong – however, they WILL ALLOW BOTH until syllabus is
corrected
● (Syllabus hasn't been corrected yet so they are allowing both)
9.1
There hasn't been a single paper that actually makes you create a single-table
database at all.
All you have to know is records are rows (one data entry) and fields are columns. Only
form of "validation" that is in any paper includes knowing the suitable data type for a
field (which is in the next point anyways).
9.2
John D 2 0 1
Sarah J 3 5 2
John D 1 2 4
Do you see the problem? We have two John D's – how would a program know which
John ordered which food? How would the program individually cater food to their
preferences?
Here comes the solution – we need some identification, which is why a CustomerID
might feel right to you. That same CustomerID is what we call a primary key.
TC0001 John D 2 0 1
TC0002 Sarah J 3 5 2
TC0003 John D 1 2 4
As mentioned earlier, we will deal with one table (of books about dogs):
Table name: DogBooks
BookNo Name Description New StockLeft
PUP001 Pomeranians All about these fluffs FALSE 102
We are going to search for the name and description of each book. Using the SELECT
statement, we can choose the fields we want like: SELECT Name, Description
(everything is case sensitive, write these "command words" (e.g. SELECT) in full upper
case. Furthermore, you can do SELECT * to choose all fields.
That becomes
SELECT Name, Description
FROM DogBooks
WHERE New
Just like an IF statement, the condition would already be a TRUE boolean so we don't
have to check if New = TRUE
Output:
Name Description
Now what if you are the librarian, and you want to sort your library by rearranging
these books into alphabetical order? Well you can use the ORDER BY keyword,
specifying the field(s) – it will rearrange the records in the order of that field's values.
This means all the corresponding values within the row will also follow the movement
of that value. You can use ASC or DESC to specify whether it is the ascending or
descending order (by default it is already ASC). If multiple fields are specified, then it
takes left to right priority (e.g. ORDER BY FirstName, LastName)
Output:
Name Description
Output:
Now what if we want to see how many books there are in total? Well we can use the
SUM function, selecting which field we want to SUM numbers up – in this case, it would
be StockLeft
This means
SELECT SUM(StockLeft)
FROM DogBooks
Output:
810
Lastly, what if the number of dog books was way bigger, and you want to count the
number of new books that just came into the library? Well you can use the COUNT
function to count the number of records in the table with the specified conditions.
Normally, you would just use COUNT(*), to count the number of records. Otherwise, it
would ignore empty values in those specific fields.
Output:
2
(still 2 as we haven't updated the original table)
Summary:
● SELECT statement
○ To choose the field(s) or a function to display
● FROM clause
○ To choose the table in the database (IGCSE you will only have
single-table databases, and the table name will be on the top of the
question most of the time)
● WHERE clause
○ To specify the conditions of the query
● ORDER BY keyword
○ To choose what field to order the query in, and whether it is ASCending or
DESCending
● SUM function
○ To output the sum of all the values of the chosen field
● COUNT function
○ To output the amount of records in the table [that matched the WHERE
clause]
Boolean logic
Truth table
A truth table is a table that shows values of output, corresponding to an input(s),
depending on the condition given. Examples can be seen below for all the different
gates.
10.1
1 0
0 1 0
1 0 0
1 1 1
OR The OR gate takes in two X = A OR B
inputs, if either inputs are 1,
A B X
it gives out 1 as output.
0 0 0
0 1 1
1 0 1
1 1 1
1 0 1
1 1 0
1 0 0
1 1 0
XOR The XOR gate takes in two X = A XOR B
inputs, if ONLY one input is
A B X
1, it gives out 1.
Logic symbol: 0 0 0
0 1 1
1 0 1
1 1 0
10.2
Logic circuits
Logic circuits are diagrams which show a logic condition visually, using inputs, outputs,
and gates.
Easy formula™
● Identify all the gates
● Draw and connect gates with inputs and outputs
● Make sure
○ Gates only take two inputs (or 1 if it is a NOT gate)
○ Lines are not too curvy
○ Examiner can identify what gate you are drawing (e.g. OR gate being too
similar/ambiguous with AND gate)
Easy formula™ (for this one, only use if you are uncertain)
● Use the working space
● Separate each logic gates into different columns, to fill out different rows
● After finishing, verify each answer quickly in your head
Answer + working:
A B C D = NOT A E = D OR B F = B XOR C Z = E AND F
0 0 0 1 1 0 0
0 0 1 1 1 1 1
0 1 0 1 1 1 1
0 1 1 1 1 0 0
1 0 0 0 0 0 0
1 0 1 0 0 1 0
1 1 0 0 1 1 1
1 1 1 0 1 0 0
Exam question - Write down the logic expression, from a drawn circuit
Easy formula™
● Start from the first two inputs, write down the expression that only requires
those two
● After that, see how it interacts with the third input
● (This may not work in questions that have very complex circuits with very
different inputs)
Answer + working(in diagram):
Mark scheme:
Exam question - write down the logic expression from a given truth
table
● As you can see, X is 1 when A, B, C are at certain combinations. If A/B/C is 0, use
a NOT gate. If A/B/C is 1, just write its letter. Then put AND gates in between
because they are at the specific combination.
● In the table below, it shows the combinations which make X equal 1
A B C Working
1 1 1 A AND B AND C