Variable
A named space in memory, large enough to store a single piece of data. Each variable has a data type
Constant
A named space in memory with a value that can never change while the program is running
Declaration
Code that causes a variable to exist. Once a variable has been declared, it can be used.
Assignment
The process of putting a value into a variable
Boolean
Can either be True or False
Character
A single letter, number, punctuation mark, space, etc.
Integer
Whole numbers - positive, negative or zero
Real
Decimal numbers - positive or negative (zero can also be stored in a 'real' variable'
String
A collection of characters, used to store names, addresses, phone numbers etc.
Sequence
Instructions will always execute in the order in which they were written. Every line will be executed once and only once.
Selection
When one path through the code is chosen where multiple possible paths exist.
Iteration
Looping. Code that is iterative might be executed multiple times, even though it is only written once.
Nesting
Placing one programming structure inside another one. There is no limit to the number of levels of nesting
Operations
An action that is performed on one or more pieces of data in order to produce additional data
Arithmetic operations
A process performed on one or more numbers. Examples include +, -, *, /, DIV and MOD
Relational operations
Logic operations
Can only have one of two outcomes - true or false. A logic operator connects together logic expressions. Examples include AND, OR and NOT
Data structure
A structured (organised) means of storing related data. While a variable can only store a single piece of data, a data structure can contain many
One-dimensional array
A data structure for storing multiple data items of the same data type. The whole array has a single name, with each element within the array having a specific index number
myArray = [4, 6, 1, 2, 9, 0]
Creates an array called 'myArray' and populates it with six integers
myArray[0] = 5
Places the number '5' into the first element (index '0') of the array
print(myArray[2])
Displays the third element of the array
Two-dimensional array
Another data structure for storing multiple data items of the same data type. Unlike a one-dimensional array, it can be considered like a grid instead of a row. Elements are referred to with two numbers.
myArray2 = [ [ 'a', 'b'] , ['c', 'd'] ]
Creates a two-dimensional array that contains four letters
myArray2 [1] [0] = 'z'
Replaces 'c' with 'z'
print(myArray2 [0] [1])
Displays the requested letter (in this case, it is 'b')
Record
A data structure that can accept multiple data items that do not need to be of the same data type
Input
The process of introducing data into a computer system
Output
The process of communicating data beyond the system, typically to a human user
File
A store of data, used by a program, that continues to exist when the program, and even the computer itself, is no longer running
fullName = firstName + ' ' + lastName
Concatenation - used to join different strings together
print(len(firstName)
Displays the length (the number of characters) in a string
fullName = 'Richard Lee' print(fullName [0:7])
Displays a substring (in this case, 'Richard')
Casting
Converting a piece of data to a specific data type
Uses of random numbers
Encrypting data, making it difficult for unauthorised people to understand
Causing simulations to run differently each time
Adding variability to computer games
Random sampling of survey participants
Subroutine
A small subsection of the whole program that performs a specific, well-defined task
Advantages of Subroutines
Each subroutine can be given to a different programmer - working as a team is straightforward
Subroutines can be tested separately
Subroutines that are commonly used can be reused in other programs, saving time and reducing errors
Parameter
A piece of data that is passed into a subroutine in order for that subroutine to do its job
Calling
A process where an instruction in one part of the code tells another named part of the code to run
Return
A command in which a subroutine passes a piece of data back to the line of code from which it was called
Difference between procedures and functions
A function is a subroutine that returns a value, and a procedure is a subroutine that does not
Modularisation
The process of breaking a program into smaller parts called modules. A subroutine is a type of module, and the advantages of dividing a program into either subroutines or modules are the same
Scope
Refers to the visibility of a variable, and can either be local or global
Advantage of global variables
Another programmer who is working on a different subroutine could modify global variables and make them behave unpredictably
Robust
A robust program continues to function even when confronted with unexpected events such as a lost network connection or a user inputting data of the wrong data type
Secure
A secure program prevents users from accessing or altering data that they should not access or alter
Validation
Ensuring that data entered into the computer is reasonable and sensible. It does not ensure that the data entered is correct
Range check
Ensures that data is within a specified range Examples: race times, ensuring a person's birthday is not after today's date
Type check
Ensures that the correct data type has been entered Examples: checking whether the type is an integer or Boolean
Length check
Ensures that the string contains a valid number of characters Examples: postcode, phone number
Lookup check
Checks that what the user has entered exists on a list, such as a list of postcodes or days of the week
Presence check
Checks that the user has entered something. Essentially a length check that ensures that the length is greater than zero.
Authentication
The software process of ensuring that the person accessing a system is the person who is supposed to access that system
Authentication methods
Usernames and Passwords
Memorable information - prompting for something that only the real user should know
Checking that the user is using their usual computer by logging the IP address
Normal (typical) test data
Data that is valid and that represents how the program would be used
Boundary (extreme) test data
Data that is just barely valid, to check that the extreme ranges of normal input work correctly. It is also good practice to test data that is just outside the acceptable range.
Erroneous
Data that should not be accepted by the system. This is included to test whether a programs validation and error messages work correctly.
High-level languages
More understandable to humans than low-level languages because the code is more similar to English, so are more popular. One line of code might do several things.
Examples: Java, Python, C#, Visual Basic
Low-level languages
More difficult to understand but can be executed very quickly by computers. Each line of code performs a single task.
Examples: Machine and Assembly code
Machine Code
Machine-specific code, which means that a machine code program written for one computer does not necessarily work on another computer. Consists of 1s and 0s.
What is needed in order to run code in high and low level languages?
High-level: Either an interpreter or a compiler, to enable code to be translated into machine code so that the computer can run it
Low-level: Machine code does not need to be translated, but assembly language requires an assembler
Suitability of high-level languages
More appropriate if the program is to be used on a variety of different computer builds
More people are proficient in high-level than low-level languages
Suitability of low-level languages
Likely to be used within embedded systems, where specific memory locations and processor functions can be addressed directly
Suited to time-critical applications, where execution must take place as quickly as possible
Translator
A program that translates source code into machine code
Assemblers
Translate assembly language - it is only used for low-level translation
Interpreters
Translate and execute high-level code, one line at a time
Compilers
Translate an entire high-level program before executing it
Advantages of Interpreters
A program that contains errors can still be run up to where the error exists
Debugging is easier, as the problematic line can be more easily pinpointed
Disadvantages of Interpreters
A program needs to be interpreted every time you run it, which is time consuming
It is easier for unauthorised people to access the source code
Advantages of Compilers
A compiled object code file will run more quickly than re-interpreting a source code file
It is more difficult for unauthorised people to modify a compiled object code file
Disadvantages of Compilers
More memory is needed for the compilation process than for interpretation
The entire program needs to be error free in order for it to compile