[go: up one dir, main page]

0% found this document useful (0 votes)
10 views9 pages

Cs Paper 2 Notes

The document outlines the Program Development Life Cycle (PDLC), detailing stages such as analysis, design, coding, and testing, along with types of test data and validation checks. It includes pseudocode examples for various programming constructs, database operations, and common definitions of programming concepts. Additionally, it provides tips for answering exam questions effectively.

Uploaded by

hishamhabib0505
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views9 pages

Cs Paper 2 Notes

The document outlines the Program Development Life Cycle (PDLC), detailing stages such as analysis, design, coding, and testing, along with types of test data and validation checks. It includes pseudocode examples for various programming constructs, database operations, and common definitions of programming concepts. Additionally, it provides tips for answering exam questions effectively.

Uploaded by

hishamhabib0505
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

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:

Code statement Pseudocode

Count control loop FOR Count ← 1 TO 50


<Code>
NEXT Count

Precondition loop WHILE <Condition> DO


<Code>
ENDWHILE

Post-condition loop REPEAT


<Code>
UNTIL <Condition>

Conditional statement IF <Condition>:


THEN
<Code>
ELIF <Condition>
<Code>
ELSE
<Code>
ENDIF

Input statement INPUT Number

Output statement OUTPUT “you said”,Number

Declaration / initialisation DECLARE Num:INTEGER

DECLARE List AS ARRAY[1:20] OF STRING

Counting Count←Count+1

Totaling Total←Total+Number

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


<Code>
ENDPROCEDURE

Declaration of function FUNCION <Name>(<Parametre n>:<Parameter n type>) RETURNS <return Type>


<Code>
RETURN <Data>
ENDFUNCTION

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

Case of a value CASE OF Num


<Value 1> : <Code>
<Value 2> : <Code>
<Value n> : <Code>
OTHERWISE <Code>
ENDCASE

Open/close file OPENFILE <File path> FOR <Access type>


<Code>
CLOSEFILE(<File path>)

Read file OPENFILE <File path> FOR READ


READFILE <Variable to store>
CLOSEFILE(<File path>)

Write file OPENFILE <File path> FOR WRITE


WRITEFILE <Variable with writing data>
CLOSEFILE(<File path>)
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 Pseudocode: LENGTH(<var>) Finds and returns the length of a


string,array or dictionary

Uppercase Returns a version of the string


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

Lowercase Returns a version of the string


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

Substring Returns a part of the string that


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:

Bubble sort:

First ← 1
Last ← 10
REPEAT
Swap ← FALSE
FOR Index ← First TO Last - 1
IF Temperature[Index] > temperature[Index + 1] THEN
Temp ← Temperature[Index]
Temperature[Index] ← Temperature[Index + 1]
Temperature[Index + 1] ← Temp
Swap ← TRUE
ENDIF
​ NEXT Index
Last ← Last - 1
UNTIL (NOT Swap) OR Last = 1
Linear search:

OUTPUT "Please enter name to find "


INPUT Name
Found ← FALSE
Counter ← 1
REPEAT
IF Name = StudentName[Counter]
THEN
Found ← TRUE
ELSE Counter ← Counter + 1
ENDIF
UNTIL Found OR Counter > ClassSize
IF Found
THEN
OUTPUT Name, " found at position ", Counter, " in the list."
ELSE
OUTPUT Name, " not found."
ENDIF

Finding maximum, minimum and average

MaximumMark ← 0
MinimumMark ← 100
FOR Counter ← 1 TO ClassSize
​ IF StudentMark[Counter] > MaximumMark
​ ​ THEN
MaximumMark ← StudentMark[Counter]
ENDIF
​ IF StudentMark[Counter] < MinimumMark
THEN
MinimumMark ← StudentMark[Counter]
ENDIF
NEXT Counter

Average (by extension)

Total ← 0
FOR Counter ← 1 TO ClassSize
Total ← Total + StudentMark[Counter]
NEXT Counter
Average ← Total / ClassSize

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 the 15 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