Paper 1 Cheat Sheet
Paper 1 Cheat Sheet
The structured approach to programming means that code is more Operation Example
logical and readable, making it easier to debug and maintain. It also Addition Pseudocode: 11 + 2 = 13
makes it more efficient. The most important part of this approach is Python example: 11 + 2 = 13
modularised programming , which is the use of subroutines. Other
Subtraction Pseudocode: 11 - 2 = 9
components include detailed code annotation and clearly named
Python example: 11 - 2 = 9
variables.
Multiplication Pseudocode: 11 x 2 = 22
Data Types Python example: 11 * 2 = 22
There are two main ways to make programs more robust. Machine Code vs Assembly Language
Firstly, using data validation, which is most easily done using an Both machine code and assembly language are low-level
IF/ELIF/ELSE statement or a TRY/EXCEPT statement. This makes languages, with assembly code having a 1:1 correspondance with
sure the data inputted by the user is valid, preventing a runtime error. machine code. However, each type of processor has its own
Secondly, authentication . This primarily takes the form of passwords. specific machine code instruction set, which is expressed in
However, testing is also key in ensuring that a program is robust. A binary. Assembly language is generally used for software for
programmer must test typical (normal), boundary (extreme), and embedded systems and for controlling specific hardware
erroneous data to guarantee that the program deals with data components.
correctly.
Translation
Most programs are initially written in high-level programming What is indefinite iteration?
languages (e.g. Python) because these are more like human
There is not set number of iterations, as it is instead dependent
languages, meaning that they are easier for programmers to
on when a certain condition becomes true.
understand, code in, and debug. They are said to provide a
Example of indefinite iteration (Python):
'higher level of abstraction' from machine code. Low-level
langages are very different and much more difficult. Despite this, while x < 5:
programming in machine code allows for the optimisation of code x = x + 1
and avoid code having to be translated.
What is nested iteration?
A loop (iteration) within a loop.
Procedures vs Functions Note that the pseudocode is not set. Different people will write their
Both take parameters, but functions return a value, whereas psuedocode differently.
procedures don't.
Local Variables
Subroutines can declare local variables, the scope of which is
limited to the subroutine. Using local variables is good practice
because it allows the program to be simpler. Global variables, on
the other hand, make a program much more complex, as they
may change frequently.
String Handling