CAIE AS LEVEL COMPUTER SCIENCE PAPER 2 (9618)
Datatypes: Identifier:
Integer: a whole number • Constant: the value cannot be changed accidently during the
Real: numbers containing a decimal point execution of the program
String: a combination of alphanumeric characters • Variable: stores a value that can change during execution.
Char: a single character • Arrays: a list of items of the same data type under a single
Boolean: True or False name.
Date: dates stored as a ‘serial’ number
Array: data stricture consisting of a collection of elements Rules for naming identifiers:
File: object that stores data/information • Must be unique
• Spaces must not be used
Algorithms: • Must begin with a letter of the alphabet
• Consists only of letters, numbers & underscore ‘_’
• Algorithm: a sequence of steps/instructions to solve a • Must not be a ‘reserved’ word – e.g. Print, If, etc.
problem
• Abstraction: filtering out and concentrating on the relevant Data:
information in a problem.
• Decomposition: breaking down problems into sub-problems • Normal data: data within the range given
in order to understand a process more clearly. • Abnormal data: data outside of the given range
• Extreme data: data that is in range but way off the median
Abstraction Advantages: • Boundary data: data at each end of the range
• Time needed for developing program is reduced • Verification: checking that data has not changed during
• Program is smaller in size transfer / input to a compiler.
• Customer satisfaction and requirements are met without any o Double entry
complex features. o Parity check
o Checksum
Stages of Algorithms: • Validation: checking that data meets certain criteria.
1. Input --> Input N1, N2 o Range check
2. Process --> N1 + N2 = Answer o Presence check
3. Output --> Print Answer o Length check
o Format check
Programming Constructs: o Character check
o Type check
• Assignment: an instruction that places a value into a
specified variable. (Answer --> “Yes”) Subroutines:
• Sequence: a number of steps performed one after the other.
(Input… Process… Output) • Subroutine – self-contained section of code, performing a
• Selection: under certain conditions some of the steps are specific task; part of the main program.
performed, otherwise none or different steps are performed. • It is used to make a more manageable and understandable
o “IF” Statement solution.
Pseudocode: IF…THEN…ELSE…ENDIF • It is used to perform a frequently used operation within a
Python: if (expression): (statements) else: (statements) program.
o “CASE” Statement
Pseudocode: CASE OF variable: … OTHERWISE: … Advantages:
ENDCASE • Allows subroutine to be called from many places
Python: if (expression): (statement) elif • The subroutine may be independently tested and debugged
(expression): statement) … else: (statement) • Changes are only made once
• Repetition/Iteration: a sequence of steps is repeated. (FOR / • Reduces unnecessary duplication
WHILE / REPEAT)
o Count – controlled loop Procedures:
▪ FOR… NEXT • Performs a specific task, but no value is returned.
o Pre – condition loop • Parameters are passed between modules:
▪ WHILE… DO… ENDWHILE o By Value – a copy of the variable itself is passed and
o Post – condition loop the original value is not changed.
▪ REPEAT… UNTIL o By Reference – the address of the variable is passed
and the original value is changed.
1
, CAIE AS LEVEL COMPUTER SCIENCE PAPER 2 (9618)
• Functions: performs a specific task, and returns a value Files:
• Refinement: the breaking down of an algorithm to a level of
sufficient detail from which it can be programmed.
• Arrays and variables are temporary memory so the data will
be lost if program gets closed.
Operator Meaning
< Less than
• Files are needed to store the data permanently
<= Less than/equal to • Write – all previous data would be deleted and a file will be
> Greater than written from scratch.
>= Greater than/equal to • Read – when searching something from an existing file.
== Equal to • Append – when adding data to an existing file rather than
!= Not equal to
creating a new one. The new data is added to the end of the
existing file.
Program Features:
▪ OPENFILE “Filename” FOR WRITE/READ/APPEND
1. Identation ▪ READFILE “Filename”, variable
2. Blank lines ▪ WRITEFILE “Filename”, “string”
3. Capitalisation of keywords ▪ CLOSEFILE “Filename”
4. Sensible variable name
5. Comments End Of File (EOF):
6. Pretty printing
• If you want to read a file from beginning to end and you don’t
• Source Code – represents a solution algorithm expressed in know when it ends.
high level language.
• Object code – produced by the compiler when translating the EOF ( )
source code.
• Pseudocode – a way of using keywords and identifiers to Functions:
describe an algorithm without following the syntax of a
particular programming language.
FUNCTION Name ( NameOfVariable : datatype , NameOfVariable
• Flowchart – graphical representation of a program in a flow. : datatype ) RETRURN Datatype
Transferrable Skills: ENDFUNCTION
• Declaration
• Assignment PROCEDURE Name ( NameOfVariable : datatype ,
• Sequence NameOfVariable : datatype )
• Selection
• Repetition / iteration ENDPROCEDURE
• Subroutines
• Input / Output
Flowcharts:
1-Dimensional Array (1D): Shapes Keywords
• Stores a list of variables of the same datatype using a single
Start / End
index.
DECLARE NameOfArray : ARRAY [ Lower bound : Upper Bound ]
OF DATATYPE Input / Output / Print
DECLARE Numbers : ARRAY [ 1 : 6 ] OF INTEGER
Assignment
2-Dimensional Array (2D):
• A multidimensional array that stores data in rows and
columns. Conditions / Loop
DECLARE NameOfArray : ARRAY [ LB Row : UB Row , LB Col : UB
Col ] OF DATATYPE Assignment related to
functions or calling function
or procedure.
DECLARE Numbers : ARRAY [ 1 : 4 , 1 : 4 ] OF INTEGER
2
, CAIE AS LEVEL COMPUTER SCIENCE PAPER 2 (9618)
Integrated Development Environment (IDE): • Test and debug program: test the program using test data,
• A software application that combines all of the features and find and correct any errors and ensure results are correct.
tools needed by a software developer. • Formalise solution: review program code, revie internal
documentation and create end-user documentation
Features: • Maintain program: provide education and support to the
• Pretty printing end-user, correct any bugs and modify if the user requests.
• Automatic Identation
• Syntax checking
• Highlight any undeclared variable Waterfall Model:
• Type checking • Used to create a system with a linear approach, from one
stage to another.
• Editor – produces/writes the source code in high level
language Advantages Disadvantages
Easy to manage, understand Difficult to change the
• Translator – converts source code into object/machine code
and use requirements at a later stage
• Debugger – used to test the program for any errors and
Stages do not overlap and are Subject to change programs
corrects them
completed on at a time are not suitable
Works well for smaller Not suitable for complex
• Program fault – something that makes the program not do programs projects.
what it is supposed to do under certain circumstances.
Initial Error Detection: Iterative Model:
• The IDE executes the code & initial error detection caried out • Incremented development as the program development
by compiler/interpreter: lifecycle is repeated. Starts with a small subset, which
o Syntax/Logic Error – before programming is run, an becomes more complex over time until the system is
error message warns the user about this complete.
o Runtime Error – run of the program ends in an
error Advantages Disadvantages
Easier to test and debug Whole system needs to be
Syntax errors: defined at the start
• When the source code does not obey rules of the language, More flexible as easier to Needs a good planning overall
and the compiler generates an error message. (grammatical after requirements and at every stage
mistakes/errors) Customer involved at each Not suitable for short simple
o Misspelled identifier / punctuation (syntax) iteration therefore no periods
o Incorrect use of a built-in function surprises when final system is
o Using the wrong datatype delivered
Run-time errors:
• Source code compiles to machine code but fails upon Rapid Application Development (RAD) Model:
execution. • A prototype model, with no (or less) specific planning put
• When the program keeps running and you have to manually into it. More emphasis on development and producing a
stop it. product-prototype. Uses previously written code where
o Division by 0 possible.
o Infinite loop
Advantages Disadvantages
Logic error: Reduced overall development System under development
time needs to be modular
• Program works but gives incorrect output
Rapid feedback informs the Need strong team of skilled
o Wrong operator used ( > instead of < )
development developers
o Misuse of logic operations
Very flexible as requirement Not suitable for short-simple
evolve from feedback projects
Program Development Life Cycle: Modification is easier because
each part must work
• Analyse problem: define the problem, record program independently
specifications and recognise inputs, process, outputs & UI.
• Design program: develop logic plan, write the algorithm in
pseudocode or flowchart and test the solution.
• Code program: translate the algorithm into high level
language with comments and produce a user interface with
executable processes.
3
Datatypes: Identifier:
Integer: a whole number • Constant: the value cannot be changed accidently during the
Real: numbers containing a decimal point execution of the program
String: a combination of alphanumeric characters • Variable: stores a value that can change during execution.
Char: a single character • Arrays: a list of items of the same data type under a single
Boolean: True or False name.
Date: dates stored as a ‘serial’ number
Array: data stricture consisting of a collection of elements Rules for naming identifiers:
File: object that stores data/information • Must be unique
• Spaces must not be used
Algorithms: • Must begin with a letter of the alphabet
• Consists only of letters, numbers & underscore ‘_’
• Algorithm: a sequence of steps/instructions to solve a • Must not be a ‘reserved’ word – e.g. Print, If, etc.
problem
• Abstraction: filtering out and concentrating on the relevant Data:
information in a problem.
• Decomposition: breaking down problems into sub-problems • Normal data: data within the range given
in order to understand a process more clearly. • Abnormal data: data outside of the given range
• Extreme data: data that is in range but way off the median
Abstraction Advantages: • Boundary data: data at each end of the range
• Time needed for developing program is reduced • Verification: checking that data has not changed during
• Program is smaller in size transfer / input to a compiler.
• Customer satisfaction and requirements are met without any o Double entry
complex features. o Parity check
o Checksum
Stages of Algorithms: • Validation: checking that data meets certain criteria.
1. Input --> Input N1, N2 o Range check
2. Process --> N1 + N2 = Answer o Presence check
3. Output --> Print Answer o Length check
o Format check
Programming Constructs: o Character check
o Type check
• Assignment: an instruction that places a value into a
specified variable. (Answer --> “Yes”) Subroutines:
• Sequence: a number of steps performed one after the other.
(Input… Process… Output) • Subroutine – self-contained section of code, performing a
• Selection: under certain conditions some of the steps are specific task; part of the main program.
performed, otherwise none or different steps are performed. • It is used to make a more manageable and understandable
o “IF” Statement solution.
Pseudocode: IF…THEN…ELSE…ENDIF • It is used to perform a frequently used operation within a
Python: if (expression): (statements) else: (statements) program.
o “CASE” Statement
Pseudocode: CASE OF variable: … OTHERWISE: … Advantages:
ENDCASE • Allows subroutine to be called from many places
Python: if (expression): (statement) elif • The subroutine may be independently tested and debugged
(expression): statement) … else: (statement) • Changes are only made once
• Repetition/Iteration: a sequence of steps is repeated. (FOR / • Reduces unnecessary duplication
WHILE / REPEAT)
o Count – controlled loop Procedures:
▪ FOR… NEXT • Performs a specific task, but no value is returned.
o Pre – condition loop • Parameters are passed between modules:
▪ WHILE… DO… ENDWHILE o By Value – a copy of the variable itself is passed and
o Post – condition loop the original value is not changed.
▪ REPEAT… UNTIL o By Reference – the address of the variable is passed
and the original value is changed.
1
, CAIE AS LEVEL COMPUTER SCIENCE PAPER 2 (9618)
• Functions: performs a specific task, and returns a value Files:
• Refinement: the breaking down of an algorithm to a level of
sufficient detail from which it can be programmed.
• Arrays and variables are temporary memory so the data will
be lost if program gets closed.
Operator Meaning
< Less than
• Files are needed to store the data permanently
<= Less than/equal to • Write – all previous data would be deleted and a file will be
> Greater than written from scratch.
>= Greater than/equal to • Read – when searching something from an existing file.
== Equal to • Append – when adding data to an existing file rather than
!= Not equal to
creating a new one. The new data is added to the end of the
existing file.
Program Features:
▪ OPENFILE “Filename” FOR WRITE/READ/APPEND
1. Identation ▪ READFILE “Filename”, variable
2. Blank lines ▪ WRITEFILE “Filename”, “string”
3. Capitalisation of keywords ▪ CLOSEFILE “Filename”
4. Sensible variable name
5. Comments End Of File (EOF):
6. Pretty printing
• If you want to read a file from beginning to end and you don’t
• Source Code – represents a solution algorithm expressed in know when it ends.
high level language.
• Object code – produced by the compiler when translating the EOF ( )
source code.
• Pseudocode – a way of using keywords and identifiers to Functions:
describe an algorithm without following the syntax of a
particular programming language.
FUNCTION Name ( NameOfVariable : datatype , NameOfVariable
• Flowchart – graphical representation of a program in a flow. : datatype ) RETRURN Datatype
Transferrable Skills: ENDFUNCTION
• Declaration
• Assignment PROCEDURE Name ( NameOfVariable : datatype ,
• Sequence NameOfVariable : datatype )
• Selection
• Repetition / iteration ENDPROCEDURE
• Subroutines
• Input / Output
Flowcharts:
1-Dimensional Array (1D): Shapes Keywords
• Stores a list of variables of the same datatype using a single
Start / End
index.
DECLARE NameOfArray : ARRAY [ Lower bound : Upper Bound ]
OF DATATYPE Input / Output / Print
DECLARE Numbers : ARRAY [ 1 : 6 ] OF INTEGER
Assignment
2-Dimensional Array (2D):
• A multidimensional array that stores data in rows and
columns. Conditions / Loop
DECLARE NameOfArray : ARRAY [ LB Row : UB Row , LB Col : UB
Col ] OF DATATYPE Assignment related to
functions or calling function
or procedure.
DECLARE Numbers : ARRAY [ 1 : 4 , 1 : 4 ] OF INTEGER
2
, CAIE AS LEVEL COMPUTER SCIENCE PAPER 2 (9618)
Integrated Development Environment (IDE): • Test and debug program: test the program using test data,
• A software application that combines all of the features and find and correct any errors and ensure results are correct.
tools needed by a software developer. • Formalise solution: review program code, revie internal
documentation and create end-user documentation
Features: • Maintain program: provide education and support to the
• Pretty printing end-user, correct any bugs and modify if the user requests.
• Automatic Identation
• Syntax checking
• Highlight any undeclared variable Waterfall Model:
• Type checking • Used to create a system with a linear approach, from one
stage to another.
• Editor – produces/writes the source code in high level
language Advantages Disadvantages
Easy to manage, understand Difficult to change the
• Translator – converts source code into object/machine code
and use requirements at a later stage
• Debugger – used to test the program for any errors and
Stages do not overlap and are Subject to change programs
corrects them
completed on at a time are not suitable
Works well for smaller Not suitable for complex
• Program fault – something that makes the program not do programs projects.
what it is supposed to do under certain circumstances.
Initial Error Detection: Iterative Model:
• The IDE executes the code & initial error detection caried out • Incremented development as the program development
by compiler/interpreter: lifecycle is repeated. Starts with a small subset, which
o Syntax/Logic Error – before programming is run, an becomes more complex over time until the system is
error message warns the user about this complete.
o Runtime Error – run of the program ends in an
error Advantages Disadvantages
Easier to test and debug Whole system needs to be
Syntax errors: defined at the start
• When the source code does not obey rules of the language, More flexible as easier to Needs a good planning overall
and the compiler generates an error message. (grammatical after requirements and at every stage
mistakes/errors) Customer involved at each Not suitable for short simple
o Misspelled identifier / punctuation (syntax) iteration therefore no periods
o Incorrect use of a built-in function surprises when final system is
o Using the wrong datatype delivered
Run-time errors:
• Source code compiles to machine code but fails upon Rapid Application Development (RAD) Model:
execution. • A prototype model, with no (or less) specific planning put
• When the program keeps running and you have to manually into it. More emphasis on development and producing a
stop it. product-prototype. Uses previously written code where
o Division by 0 possible.
o Infinite loop
Advantages Disadvantages
Logic error: Reduced overall development System under development
time needs to be modular
• Program works but gives incorrect output
Rapid feedback informs the Need strong team of skilled
o Wrong operator used ( > instead of < )
development developers
o Misuse of logic operations
Very flexible as requirement Not suitable for short-simple
evolve from feedback projects
Program Development Life Cycle: Modification is easier because
each part must work
• Analyse problem: define the problem, record program independently
specifications and recognise inputs, process, outputs & UI.
• Design program: develop logic plan, write the algorithm in
pseudocode or flowchart and test the solution.
• Code program: translate the algorithm into high level
language with comments and produce a user interface with
executable processes.
3