0% found this document useful (0 votes)
3 views

CS PAPER 2 Revision

The document outlines the Program Development Life Cycle (PDLC), which includes analysis, design, coding, and testing phases. It also details various types of test data, validation and verification checks, and provides examples of pseudocode and Python code structures. Additionally, it covers database concepts such as data types, creating tables, inserting values, and updating records.

Uploaded by

justvarr24
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

CS PAPER 2 Revision

The document outlines the Program Development Life Cycle (PDLC), which includes analysis, design, coding, and testing phases. It also details various types of test data, validation and verification checks, and provides examples of pseudocode and Python code structures. Additionally, it covers database concepts such as data types, creating tables, inserting values, and updating records.

Uploaded by

justvarr24
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

(don't forget to leave an upvote on the post 😀)​

Quick revision Notes


Computer science paper 2
The program development life cycle(PDLC):

➢​ 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:

Pseudocode and Python code:

Code statement Pseudocode Python Code

Count control loop FOR Count ← 1 TO 50 for i in range(50):


<Code> <Code>
NEXT Count

Precondition loop WHILE <Condition> DO while <Condition>:


<Code> <Code>
ENDWHILE

Post-condition loop REPEAT while (True):​


<Code> <Code>
UNTIL <Condition> if <Condition> :
break

Conditional statement IF <Condition>: if <Condition>:


THEN <Code>
<Code> elif <Condition>:
ELIF <Condition> <Code>
<Code> else:
ELSE <Code>
<Code>
ENDIF

Input statement INPUT Number Number=input(<Prompt>)

Output statement OUTPUT “you said”,Number print(“you said”,Number)

Declaration / initialisation DECLARE Num:INTEGER Num=0


List=[“” for i in range(20)]
DECLARE List AS ARRAY[1:20] OF STRING

Counting Count←Count+1 Count += 1

Totaling Total←Total+Number Total += Number


Declaration of procedure PROCEDURE <Name>(<Parametre n>:<Parameter n type>) def <Name>(<Parameter n>):
<Code> <Code>
ENDPROCEDURE

Declaration of function FUNCION <Name>(<Parametre n>:<Parameter n type>) RETURNS <return Type> def <Name>(<Parameter n>):
<Code> <Code>
RETURN <Data>
return<data>
ENDFUNCTION

Calling procedure/function Num ← CALL <Name>(<Parameters>) Num = <Name>(<Parameters>)

Case of a value CASE OF Num if <Condition>:


<Value 1> : <Code> <Code>
<Value 2> : <Code> elif <Condition>:
<Value n> : <Code> <Code>
OTHERWISE <Code> else:
ENDCASE <Code>

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)

Name Sign/function purpose

add ‘+’ Add/concatenate 2 values

subtract ‘-’ Subtract 2 values

Divide ‘/’ Divide 2 numbers

integer Divide DIV (or) ‘//’ Divide 2 numbers and return


integer quotient

Modulus MOD (or) ‘%’ Divide 2 numbers and return


integer remainder

Length Python: len(<var>) Finds and returns the length of a


(or) string,array or dictionary
Pseudocode: LENGTH(<var>)

Uppercase Python: <str>.upper() Returns a version of the string


(or) with all characters in upper case
Pseudocode: UCASE(<str>)

Lowercase Python: <str>.lower() Returns a version of the string


(or) with all characters in lower case
Pseudocode: LCASE(<str>)

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.

Database data types:


Data type Example Description
Text “Hello world”​ A group or ‘string’ of characters
(OR)
‘Hello 1234’
Character “M” (OR) ‘4’ A single character

Boolean TRUE (OR) FALSE A value that can either be


{true,1,yes} or {false,0,no}
Integer 9 A whole number

Real 20.35 A decimal value


Date/Time “22/11/2024” (or) “22:43:10.33” A date or time value

Records and fields:


Records are the rows
Fields are the columns
Field 1 Field 2 Field 3 Field 4 Field 5
Record 1
Record 2
Record 3
Record 4
Create a table:
Format: EXAMPLE:
CREATE TABLE <table name>( CREATE TABLE Students (
<Field Name> <Field Type> PRIMARY KEY, StudentID TEXT NOT NULL PRIMARY KEY,
<Field Name> <Field Type> , StudentName TEXT NOT NULL,
<Field Name> <Field Type> ); StudentGrade INTEGER NOT NULL,
StudentDOB DATE NOT NULL,
StudentAvgMarks REAL NOT NULL,
StudentGender CHARACTER NOT NULL,
IsStudentTopper BOOLEAN NOT NULL);

Insert values into table:


INSERT INTO <table name> VALUES (<value1>,<value 2>,…<value n>);

Inserts a record of all values given for each field into the specified table name

Output from database:


SELECT <fields> FROM <table name> WHERE <condition> ORDER BY <field> DESC ;

[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}

Update value in database:


UPDATE <table name> SET <field> = <new value> WHERE <condition>;

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:

1D/2D array handling #1D array:


Var = Array[<pos>]
Array.append(<Value>)

#2D array:
Var = Array[<Row number>,<Column number>]
Array[<Row number>].append(<Value>)

Bubble sort for x in range(len(array)):


for i in range(len(array)-1):
if array[i] > array[i+1]:
array[i] , array[i+1] = array[i+1] , array[i]

Linear search Var = <Value to find>


for i in range(len(<Array>)):
if array[i]==Var:
<Position of Var> = i

Tips and tricks:


●​ 15 mark Q:
○​ In the 15 mark Q add a comment addressing the bullet point before the code
for that point is written(example: “#getting wood type from user using integer
input”)
○​ In the15 mark Q Always add comments before a programming method(e.g.
Bubble sort or linear search) stating the method used and the purpose.
○​ Allocate half a page for declaration of variables and initialization before
moving onto the code in the 15 mark question
○​ Add checkboxes next to the bullet points in the 15 mark question.Tick them
off when your done with each bullet point
○​ Underline the conditions specified in the 15 mark question and refer to them
as you write the program

●​ Error identification and correction Q:


○​ In the error identification question always check for syntax errors throughout
the code before moving onto the logical errors(At Least 1 error is guaranteed)
○​ It is very common to have at least one error due to switched up operators(e.g.
“<” instead of “>” ,”←” instead of “=”)

●​ Pseudocode writing Q:
○​ Always recheck the “AND” and “OR” operators in a conditional statement as
they are easy to confuse

You might also like