CS PAPER 2 Revision
CS PAPER 2 Revision
➢ Analysis:
○ Analysing the problem to be solved by clearly defining it
○ Involves “Abstraction” where unnecessary details to the problem is discarded
○ Involves “Decomposition” to exactly determine the requirements of the
program by breaking the problem into smaller pieces
➢ Design:
○ Shows how the program can be developed,By formally documenting it using
structure diagrams,flowcharts,pseudocode
➢ Coding(And iterative testing):
○ The program or set of programs are developed,each module of the program
is then tested and edited to work as intended before moving onto the next
module.
➢ Testing:
○ The program is tested with different types of test data to make sure it is
working as intended and solves the initial problem
Test data:
➢ Normal test data:
○ Data that the program should accept,used to check if program accepts and
process expected data
➢ Abnormal test data:
○ Data that the program should reject,Used to check if the program rejects data
that should not be accepted
➢ Extreme test data:
○ Data that the program should accept,Used to check if the program accepts
the lowest and highest values that should be accepted
➢ Boundary test data:
○ Data that the program should accept and reject,Used to check if the program
accepts the lowest and highest values that should be accepted and rejects
their counterparts above and below the accepted range.
Validation checks:
➢ Length checks: Checks for the length of a string/array
➢ Range check: Checks if number is within a specific range
➢ Type check: Checks the variable type of a variable
➢ Presence check: Checks if there is a value present in input
➢ Format check: Checks if the input follows a specific format
➢ Check digits: Checks if the value was entered incorrectly
Verification checks:
➢ Double entry: Input is given 2 times to see if they match
➢ Screen/Visual check: A check by the user ensure the input is valid
Decomposing a problem:
The component parts of any computer system are:
➢ Inputs
➢ Processes
➢ Outputs
➢ Storage
Flowcharts:
Structure diagram:
Declaration of function FUNCION <Name>(<Parametre n>:<Parameter n type>) RETURNS <return Type> def <Name>(<Parameter n>):
<Code> <Code>
RETURN <Data>
return<data>
ENDFUNCTION
Open/close file OPENFILE <File path> FOR <Access type> Var= open(<File path>,<access type>):
<Code> close(Var)
CLOSEFILE(<File path>)
Read file OPENFILE <File path> FOR READ Var= open(<File path>,”r”):
READFILE <Variable to store> File_contenets = Var.read()
CLOSEFILE(<File path>) close(Var)
Write file OPENFILE <File path> FOR WRITE Var= open(<File path>,”w”):
WRITEFILE <Variable with writing data> Var.write(<Data>)
CLOSEFILE(<File path>) close(Var)
Substring Python: <Str>[<Start char pos> : <End char pos>] Returns a part of the string that
(or)
SUBSTRING(<str>,<start char pos>,<length>) is specified
Common definitions:
● Constant: Used to store values that do not change throughout the program;Ex: pi.
● Variables: Used to store values that do change throughout the program or in runtime;Ex:
Looping variables.
● Functions: A group of programming statements under a defined name that can be called
repeatedly through the program with the defined name,the function returns a value back to
the program it was called in;Ex: a function to do integer division.
● Procedures: A group of programming statements under a defined name that can be called
repeatedly through the program with the defined name,the procedure does not return a value
back to the program it was called in.
● Local variables: A local variable is a variable that can only be used in the module of code it
was defined in,it does not have a special syntax to initialize it.
● Global variables: A global variable is a variable that can be used anywhere in the code it
was defined in,it does have a special syntax to initialise it.
Inserts a record of all values given for each field into the specified table name
[Text in blue]: Select the values of a field from a specified table, this part of the statement is necessary.
Ex: SELECT code, price FROM Items {returns fields codes and price from table items}
[Text in orange]: Selects the values from the field only if the condition is true, not necessary for the statement to
work.
Ex: SELECT * FROM Items WHERE Price > 250 {returns the whole record of any item with a price over
250}
[Text in purple]: Returns the values in alphabetical order, if DESC is specified then the order is reversed, not
necessary for the statement to work.
Ex: SELECT Item_code FROM Items ORDER BY Item_name {returns items codes by the alphabetical order
of its name}
Extras:
SELECT SUM (<Field>) {Returns the sum of the values in the field, field should be INT or REAL}
SELECT COUNT (<Field>) {Returns the number of records for that field}
Updates the values in the field of a specified table to the new value where the condition is true.
The condition is not necessary.
Logic gates:
Python/Pseudocode methods to know:
Method: Code:
#2D array:
Var = Array[<Row number>,<Column number>]
Array[<Row number>].append(<Value>)
● Pseudocode writing Q:
○ Always recheck the “AND” and “OR” operators in a conditional statement as
they are easy to confuse