authentication gcse computer science (9-1) revision cards · either even or odd 1s in the number. 1...
TRANSCRIPT
GCSE Computer Science (9-1)
Revision Cards
ko-fi.com/A487H04
Authentication
Part of Defensive Design, authentication confirms the identity of the user before they are allowed to access the system. ★ CAPTCHA ★ Password ★ Biometric
CAPTCHA
Completely Automated Public Turing tests to tell Computers and Humans Apart Uses heuristics to determine if the computer user is a human such as ... ★ Clicking in a box ★ Performing a simple sum ★ Identifying street signs in images Started life as reCAPTCHA which digitised old books and magazines.
Password Strength
Strong passwords have ... ★ Mixture of upper case, lower case,
numbers and symbols ★ Non-consecutive character types ★ Combinations of unrelated words Passwords authenticate based on the fact that you are the only one who knows it!
Biometrics
Uses behavioural or physiological qualities to identify you. Behavioural ★ Keystrokes ★ Mouse movements ★ Signatures ★ Voice ★ Body position / gait Physiological ★ Fingerprint ★ Hand ★ Iris / Retina ★ Face ★ DNA Consider the ethical issues surrounding the use of personally identifiable data.
Subprograms / subroutines
Used to avoid code repetition, structure code properly and make code more readable. Variables inside subroutines are local (unless specified as global) and are only available to the subroutine.
Decomposition
Breaking a larger problem apart in order to make it easier or more straightforward to solve. Can often reveal patterns which allow previous solutions to be applied to new situations.
Procedures
Subprograms which sometimes take parameters but never return values. Used mainly to structure code and avoid reptition of code in a whole solution.
Functions
Subprograms which always take parameters and always return a value to the callee. Used to hide a mathematical or logical operation behind a simple interface.
Arrays
Allow data to be collected, accessed and manipulated under one variable name. Each item in an array is accessed using its index. Technically, arrays are fixed length data structures which need to be declared before they are used. For instance, to create a 7 element array, diggers ...
ARRAY diggers(7)
Pseudocode
One dimensional array
Behaves like a single list. Each item is accessed using its index.
0 1 2 3 4
names Mark Fred Alice Leanne Tracy
>>> names[2] 'Alice'
Python REPL
Two dimensional array
Behaves like a table. Each value can be accessed using a combination of its row index followed by its column index.
scores 0 1 2 3 4
0 5 2 4 7 2
1 2 3 7 6 4
2 6 2 1 4 6
3 8 4 9 2 4
4 4 5 2 7 8
>>> scores[3][2] 9
Python
List methods
Enable operations on lists. Vary with programming languages but in Python ...
list.append(item) list.insert(position,item) list.sort() list.pop() list.count(item) list.reverse() list.index(item) separator.join(list)
Python
Dictionaries
References values via a key rather than via an index.
cars = {"red":3, "blue":5, "yellow":2}
>>> cars["blue"] 5
Python
Character methods
Converting ASCII code to single characters and characters to ASCII codes.
>>> chr(70) 'F' >>> ord('F') 70
Python REPL
Characters
Letters, numbers and symbols are represented with a binary code through use of an encoding table. Encoding tables don't describe how the characters should be displayed. ASCII Standard character set of 128 characters used globally. Stands for "American Standard Code for Information Interchange". Extended ASCII One extra bit allows 256 characters. Unicode 16 or 32 bit encoding tables designed to cover every possible character in every known language.
Network protocols
A set of agreed standards designed to make communication fast, reliable and error free. De Jure Standards which are governed by written / published rules which everyone adheres to. De Facto Standards which are accepted because they are most common.
Media Access Control (MAC) address
Every networkable device in the world has a different MAC address used to uniquely identify the device. 48 bit binary code written in hexadecimal (makes it easier to read / recognise).
11110000-11011110-11110001-10010100-11010010-01101010
↓ F0-DE-F1-94-D2-6A
Used by switches to direct data to the correct devices in a network. MAC addresses are like house numbers - they identify individual devices.
Internet Protocol (IP) address
Used by routers to send data across a network. IP addresses are hardware independent (unlike MAC addresses). IP addresses can be static (stays the same) or dynamic (changes regularly).
01000000.11101001.10100111.01011110
↓
64.233.167.94 IP Addresses are like postcodes and give the location of a computer / group of computers.
The Internet
A publically accessible network of networks - the largest WAN. ★ A vast, global collection of
hardware, computers, cables satellites.
★ No central management. ★ NOT the same as the World Wide Web
The World Wide Web (WWW)
A collection of websites hosted on web-servers accessed on the Internet using the HTTP / HTTPS protocols.
Unform Resource Locator (URL)
Proper name for a website address.
Domain Name System (DNS)
Maps domain names (website addresses) to IP addresses so you don't have to remember the IP address of your favourite website.
The Cloud
★ Data is hosted in 'server farms' all over the world
★ Massive 'redundancy' makes data secure
★ Must be connected to a network to access data
★ Elastic storage ★ Monthly fees can be high ★ Data can be accessed from everywhere
in the world ★ Major benefit : offsite backup
Check digits
A digit added to the end of a sequence of numbers or characters which is calculated from numbers or characters in the sequence. Used to check for errors.
Check digits Parity bit
Most significant (leftmost) bit in a binary string is toggled to enforce either even or odd 1s in the number.
1 0 1 1 0 0 0
Original value - three 1s
1 1 0 1 1 0 0 0
Converted to EVEN parity
0 1 0 1 1 0 0 0
Converted to ODD parity
Check digits Checksum
Value calculated from the other values in the number. Calculated using a hashing algorithm. ★ ISBN number ★ MD5 hash
ARQs
Automatic Repeat Request. This is an error control mechanism for data transmission which uses ACKnowledgements and timeouts to achieve reliable data transmission over an unreliable service.
Cookies
Simple text files which websites store on your computer when you visit them. The cookie uniquely identifies you to the website and allows them to offer you personalised experiences ... ★ Personalisation options ★ Contents of your basket ★ Most recent browsed pages ★ Login information
What is a cookie?
Parallel and serial transmission
Parallel : data sent simultaneously Serial : data send individually
Simplex, half-duplex, full-duplex
Direction of transmission and whether transmission can occur in both directions at once.
Caeser cipher
Rotating shift cipher used in simple types of encryption.
Caeser Cipher
Key of 6
Comparison operators
A comparison operation compares two values (the operands) and returns either True or False dependant on the comparison being performed
== Is the same as
<> or != Is not the same as
< Is less than
<= Is less than or equal to
> Is greater than
>= Is greater than or equal to
Boolean operators
Logical operator used to combine multiple True / False conditions to form more complex conditions.
x AND y Returns True if both x and y are True, False otherwise.
x OR y Returns True if either x or y or both x and y are True, False otherwise.
NOT x Returns True if x is False and False if x is True.
Utility software Degfragmentation
Reorganises files on the surface of hard disk drives to make them 'contiguous' - in order. Provides faster file access. Not used for SSD as extra write operations shortens the lifespan of the drive.
Utility software Backup / archiving
Safeguards data from accidental loss, corruption or theft. Full Backup of every file is taken Takes a long time to complete Incremental Only files which have changed Less storage space required
Utility software Compression
Uses special algorithms to reduce size of files. Helps to save storage space and also speed up data transfer. Standard file types are ZIP, RAR.
Utility software Encryption
Scrambles sensitive data using a 'key' (usually a password) to stop other people / computers reading the data.
Open-source software
Source code (program code) is freely available and compiled 'binaries' can be downloaded for free. Anyone can modify the source code to create their own 'forks' and share. ★ Apache web server ★ Google Chrome ★ Android OS ★ Firefox browser ★ VLC media player ★ GIMP (Graphics software) ★ Libre Office ★ FileZilla
Proprietary / closed-source software
Source code (program code) is compliled to keep it secret and not released. Often, though not always, paid software. ★ Microsoft Office ★ Adobe Creative Suite ★ Apple iOS
Program languages Generations
Computers understand binary (machine code) whereas humans understand formal languages (English like).
Programming languages Levels
LOW Level ★ 1:1 mapping instructions to binary ★ Machine / processor dependent ★ Hard for humans to understand ★ Programs are very fast / efficient HIGH level ★ 1:N mapping instructions to binary ★ Machine / processor independent ★ Easy for humans to understand ★ Programs are slow / less efficient
Language translators Assembler
Translates mnemonic based assembly code into machine code all at once.
Each processor type has its own dedicated assembler.
Language translators Compiler
Translates the whole of the source code into object code (machine code) which is then executed by the processor.
★ Compilation happens once ★ Errors generated at compilation ★ Compiler is not required again ★ Object code runs quickly ★ Examples : C++, VB
Language translator Interpreter
An interpreter executes the instructions in the source code directly one line at a time rather than converting it to object code and asking the processor to execute it.
★ Interpreter required every time ★ Interpreter halts execution on errors
- useful for debugging ★ Source code runs slowly ★ Examples : Python, PHP, Javascript
Integrated Development Environment (IDE)
★ Code editor ★ Run-time environment ★ Code navigation tools ★ File navigation tools ★ Breakpoint / stepping tools ★ Debugging tools ★ Error diagnosis ★ Auto-documentation
Geany IDE
Computer system
Any machine that has ... ★ Input ★ Processing ★ Storage ★ Output Computer systems were created to process data faster and more accurately than humans.
Hardware
The physical components of a computer system that you can touch. ★ Motherboard ★ CPU ★ Memory ★ Monitor ★ Printer ★ Power supply ★ Hard disk drive ★ Optical drive ★ Graphics card
Software
The applications / programs that a computer system runs. ★ Operating system ★ Word processor ★ Presentation software ★ Web browser ★ Virus checker
Embedded system
Computer systems built into another device They are single printed circuit boards that include the processor, memory, input and output interfaces. For example ... ★ Digital camera ★ Microwave ★ Washing machine ★ Engine management system ★ Traffic light Embedded systems are often more efficient than general purpose computers because they have fewer components and are designed to perform just one task.
Local Area Network (LAN)
A network of computers in a small geographical area (building, office, site). The hardware is owned by the organisation. Enables sharing of ... ★ Files ★ Printers / Storage ★ Internet connection Centralised account management
Wide Area Network (WAN)
A WAN connects LANs from different geographical areas. The hardware in a WAN is owned by different organisations. Commonly called an 'internet'. The most common WAN is the Internet (note the capital 'I').
Performance of networks
Affected by ... ★ Bandwidth ★ Number of users sharing connection ★ Connection method (wired, wireless,
optical fibre) ★ Type of hardware used ★ Topology (layout)
Network Interface Controller (NIC)
A hardware card built into a motherboard or sometimes as a separate card that allows the computer to connect to a LAN via wired or wireless connection.
Network switch
Intelligent device with multiple NICs (32 or 64) which transmit data between computers based on their Media Access Control (MAC) addresses.
Router / Router switch
Device responsible for transmitting (or routing) data between networks based on their Internet Protocol (IP) address. Transmits data in packets. Often used in homes and businesses for connecting a LAN to the Internet (WAN). Home routers are actually 'router / switches' and often provide a Wireless Access Point (WAP).
Cables
Ethernet (CAT5) ★ Stranded copper ★ "Twisted pair" ★ Short distance ★ Home / office Coaxial ★ Single copper ★ Shielded to prevent interference ★ Short distance Fibre Optic ★ Plastic / glass ★ Transmit data with light ★ Long distance ★ Does not suffer from interference
Wireless (Wi-Fi)
★ Radio frequency transmission on 2.4GHz or 5GHz channels
★ Overlapping channels cause interference
★ Requires Wireless Access Point (WAP) / Wireless switch
★ Implemented using security (WPA, WPA2 or TKIP)
Client-server network
Network managed by a server which handles logins, file sharing, permissions. All other devices are clients (wired or wireless).
★ Mainly used in businesses ★ Relience on server ★ Central managment
Peer-to-peer network
All machines are 'equal'. Users, files and permissions are managed at the individual machines.
★ Home networks ★ All machines equal ★ No centralised managment
Star network topology (layout)
Network is physically laid out in a star shape. All devices connected together using a single switch or hub.
★ Cheap ★ Reliable ★ Relience on switch
Mesh network topology (layout)
Each device is connected directly to each other device. Mainly implemented using Wireless rather than cable.
★ New technology ★ Fastest routes used
Virtual network
A private, software based network using existing physical hardware by reserving resources. Virtual Private Network (VPN) Secure virtual network used for transferring files / data securely.
Benefits of networking
Sharing resources ★ Printers ★ Internet connection ★ Files ★ Communication ★ Centralised management
Network policies
A good network policy should advise ... ★ Regular security testing ★ Insistence on strong passwords ★ Regular password updates ★ User access levels ★ Antivirus / firewall software ★ No removable media ★ Encryption
Penetration testing
White hat hackers employed to test for vulnerabilities in a computer system and report back to company.
Network forensics
Investigating logs, capturing data packets, inspecting files to locate network vulnerabilities.
Network security methods
★ Updated software / patches ★ Authentication ★ Encryption ★ Passwords ★ Firewalls ★ Proxy servers ★ MAC address filtering ★ Secure Socket Layer (SSL) ★ Transport Layer Security (TLS) ★ Anti-malware software ★ Physical security
Network security attacks
Types of security attacks ... ★ Passive ★ Active ★ Insider ★ Brute force ★ Denial-of-service
Malware
Types ★ Virus ★ Worm ★ Trojan Actions ★ Deleting / modifying files ★ Scareware ★ Locking files (ransomware) ★ Spyware ★ Rootkits
Social engineering
Gaining access to a computer resource by tricking people. ★ Telephone scams ★ Phishing ★ Pharming ★ Shoulder surfing
SQL Injection
Using a special language called Structured Query Language (SQL) to trick a website database into revealing data. The SQL code is either included in the website address or typed in web forms. Very hard to detect but incredibly powerful hacking tool. Database must be very secure.
Databases Structure
Persistent, organised store of data organised using tables, record and fields. Fields
id name dob dept pay
Records
1 John 15.01.75 J2 19000
2 Karen 27.07.90 J5 27000
3 Bert 12.08.65 Z1 26000
PK
Each record has a Primary Key (PK) which is used to identify it in the table. Each field can only have one data type but each record can have a mix of data types.
Databases CREATE TABLE
Structured Query Language statement used to create a table. List each field followed by its data type and indicate whether it is the primary key for the table.
CREATE TABLE employees ( id INTEGER PRIMARY KEY name TEXT dob DATE dept TEXT pay INTEGER )
SQL
Databases INSERT INTO
Structured Query Language command used to insert data into a table ...
INSERT INTO employees VALUES (1,'John',15.01.75,'J2',19000) (2,'Karen',27.07.70,'J5',27000) (3,'Bert',12.08.65,'Z1',26000)
SQL
You can also insert individual fields (the other fields take a default or automatic value) ...
INSERT INTO employees (name,dob,dept,pay) ('John',15.01.75,'J2',19000) ('Karen',27.07.70,'J5',27000) ('Bert',12.08.65,'Z1',26000)
SQL
Databases UPDATE
Used to update records by searching for a record using the value in one of its field and specifying a new value for its fields. Update Karens pay
UPDATE employees SET salary = 29000 WHERE id = 2
SQL
Databases SELECT
Retrieve data from the database by searching for values in given fields. All details for all employees
SELECT * FROM employees
SQL
Employees
SELECT name FROM employees
SQL
Employees and their pay
SELECT name, pay FROM employees
SQL
Databases SELECT WHERE
Filter data from a database based on criteria / patterns Employees with pay > 20000
SELECT name FROM employees WHERE pay > 20000
SQL
Employees with pay > 20000 in dept J5
SELECT name FROM employees WHERE pay > 20000 AND dept = 'J5'
SQL
Employees with pay > 20000 or in departmentss starting with the letter J
SELECT name FROM employees WHERE pay > 20000 OR dept LIKE 'J%'
SQL
Databases ORDER BY
Order the results in ASCending or DESCending order of the specified field name. Employees and pay in descending order of pay
SELECT name, pay FROM employees ORDER BY pay DESC
SQL
Employees and dob in ascending order of dob
SELECT name, dob FROM employees ORDER BY dob ASC
SQL
Assignment
Storing a value in the computers memory and labelling it with a 'name' to allow you to make reference to it later in your code.
>>> name = 'Tarquin' >>> widgets = 12 >>> price = 9.62 >>> paid = False
Python REPL
name ← 'Tarquin' widgets ← 12 price ← 9.62 paid ← False
Pseudocode
The assignment operator is the single equals sign (=). This does not mean 'is the same as' ...
Variables / variable names
A value in the computers memory which can change during program execution. Variables are given a name to allow you to make reference to them during program operation. There are rules to variable names : ★ Only letters, numbers and underscores ★ Can't start with a number ★ Cannot be a keyword from the
programming language ★ Cannot contain spaces
Constants
Values stored in the computers memory which are not changed during program execution. Constants allow ... ★ Mathematical values (like π) to be
represented in the code as a name rather than a value.
★ Values to be referenced in the code using a name rather than a value allowing the value to be used many times in the code.
Constants are generally written in CAPITAL LETTERS ...
>>> PI = 3.14159265 >>> PAYRATE = 16.52
Python
Input
Asking the person using the computer to either type something in using the keyboard or select something using a mouse or get a signal from a sensor.
>>> name = input('Enter your name : ') Enter your name : Mark >>> print(name) Mark
Python
Programmer VS User
Programmer Generally an expert in programming in charge of solving a problem by gathering information from users and processing it. Has a fixed idea of what the program should do. User Generally not experts in programming. Will need to be given lots of prompts to make sure that they enter the correct information. Often impatient. Flexible view of what the program should do.
Concatenation
Joining together, normally strings
>>> name = 'Mark' >>> town = 'Oldham' >>> print(name + ' from ' + town) Mark from Oldham >>> print(name,'from',town) Mark from Oldham
Python
Binary numbers Addition
Rules 0 + 0 = 0 (obvious) 0 + 1 = 1 (obvious) 1 + 0 = 1 (obvious) 1 + 1 = 10 (not so obvious) 1 + 1 + 1 = 11 (not so obvious)
Binary numbers Arithmetic shifts
Left shift multiplies by 2
Right shift divides by 2
(Just like left and right shifts in denary multiply and divide by 10!)
Binary numbers Overflow
If a binary addition or a left shift results in a number which is too big to fit in the number of bits available.
Binary numbers Negative numbers
Using two's complement method. For example, to represent -28 ...
128 64 32 16 8 4 2 1
28 0 0 0 1 1 1 0 0
NOT 1 1 1 0 0 0 1 1
-128 64 32 16 8 4 2 1
+1 1 1 1 0 0 1 0 0
Represents : -128 + 64 + 32 + 4 = -28
Programming errors
(Part of Defensive Design) Syntax errors Caused by mistakes in the grammar of the language - make sure you type your code correctly! Runtime errors Use validation including try-except routines to trap unexpected errors. Semantic / logic errors Check the operation of the code manually through trace tables.
Testing strategies
(Part of Defensive Design) Unit testing Individual routines are tested independently (white or black box). Integration testing Routines are combined together to make sure they interact correctly System testing Make sure the system solves the original problem Acceptance testing Check whether software is suitable for client and delivery.
Test data
(Part of Defensive Design) Boundary data Values which are used to check the inner and outer edges of validation ranges. Normal data Values which lie within the edges of validation ranges. Erroneous data Values which should be rejected outright, for instance, outside range or wrong data types.
Black box and white box testing
(Part of Defensive Design) A white box test involves the tester (normally the programmer) testing the units, combinations of units or the entire system with complete knowledge of the underlying code. A black box test involves the tester (often not a programmer) testing combinations of units or the whole system without any awareness of the underlying code. Can also happen during acceptance testing.
Testing table structure
(Part of Defensive Design) Columns in testing table ★ Test reference ★ Scope of test ★ Type (BNE) ★ Input values ★ Expected result (Reference) ★ Actual result (Reference) ★ Corrective action (Reference)
Input devices
Manual input of data ★ 2D / 3D scanners ★ Barcode readers ★ Quick Response (QR) code readers ★ Digital cameras ★ Keyboards ★ Mice ★ Touch screen ★ Interactive whiteboards ★ Microphones
Sensors
Automatic input of data ★ Light ★ Temperature ★ Magnetic field ★ Gas ★ Pressure ★ Moisture ★ Humidity ★ pH ★ Motion
Output devices
★ Inkjet printer ★ Laser printer ★ 3D printer ★ 2D and 3D cutters ★ Speakers and headphones ★ Actuators ★ LCD display ★ LED display
Random Access Memory (RAM)
Volatile primary storage which holds the data and instructions / programs currently executing and requires power to retain it's data. The 'random' in RAM means that the memory can be accessed directly rather then sequentially (one after another). RAM can be read from or written to.
Read Only Memory (ROM)
Non volatile - does not need power to hold it's data. Holds the boot up program used when the computer first starts (boot strap) known as the BIOS (basic input output system). Can only be read from, not written to. Can be 'flashed' (reprogrammed) using special software or hardware.
Basic Input Output System (BIOS)
Instructions held in ROM which tell the computer how to boot up correctly. Performs self checks of memory and check which hardware is present loading certain device drivers.
Virtual memory
An area on the hard disk used as memory. Used when RAM is too small to deal with the amount of instructions. Effects the performance of the computer because the access time on the hard disk drive is slow.
Iteration / Repetition FOR-NEXT
Counter controlled loop will work through every value in an 'iterable' object (range, string, list) setting a loop variable to each value in the iterable in turn.
FOR value IN iterable for_body
Pseudocode
The for_body tends to use the value from the iterable in its operations.
Iteration / Repetition WHILE
Condition controlled loop which checks a condition at the start and only executes its body if the condition is TRUE .
WHILE condition while_body
Pseudocode
Iteration / Repetition REPEAT-UNTIL
Condition controlled loop which checks a condition at the end of the body and only executes its body again if the condition is FALSE .
REPEAT repeat_body UNTIL condition
Pseudocode
Iteration / Repetition DO-WHILE
Condition controlled loop which checks a condition at the end of the body and only executes its body again if the condition is TRUE .
DO do_body WHILE condition
Pseudocode
Types of storage
Primary storage (mostly volatile) ★ CPU registers ★ RAM ★ ROM Secondary storage (non-volatile) ★ Hard Disk Drives ★ Solid State Drives ★ Compact Disk (offline) ★ Flash drives (offline) ★ Secure Digital Cards (offline) Tertiary storage (non-volatile) ★ Magnetic tape
Hard Disk Drive (HDD)
Internal storage device. Made from magnetised metal 'platter' - data is written and read using an arm.
★ High capacity ★ Fragile ★ Cheap / MB ★ Long life
Solid State Drive (SDD)
Internal secondary storage devices with no moving parts. ★ Much faster than HDD ★ More robust ★ Expensive / MB ★ Don't slow with fragmentation of
files
Flash memory
Solid-state memory used as low cost secondary storage in portable devices and as removable memory, e.g. ★ USB memory stick / flash drive ★ Secure Digital Card (SD) ★ Micro SD Card
Optical disc
Data is read and written using low power laser. Technique varies between discs. ★ Compact Disc (CD) 700MB ★ Digital Versatile Disc (DVD) 4.7GB ★ Blu-Ray 25GB
Magnetic tape
Single length (>250m) of plastic tape covered in magnetic particles. ★ Very low cost / MB ★ Very slow read / write speeds ★ Used for archive / backup ★ Sequential (in order) access
File handling
Store data in text or binary format on secondary storage.
open Create a file handle to allow access to the file through a name
read Retreive from a file
write Write data to a file, erasing the contents in the process
append Write data to a file, keeping the contents and adding it to the end
close Disconnect the file handle
Allows data to be saved between sessions of the program running.
Assessing choice for storage
Consider ... ★ Reliability ★ Speed ★ Capacity ★ Durability ★ Cost ★ Portability
Logic gates AND
BOTH inputs need to be ON (1) for the output to be ON (1)
A B Q
0 0 0
0 1 0
1 0 0
1 1 1
Logic gates OR
At least one inputs need to be ON (1) for output to be ON (1)
A B Q
0 0 0
0 1 0
1 0 0
1 1 1
Logic gates NOT
The output is opposite to the input
A Q
0 1
1 0
Logic gates Truth table
A table that contains all of the inputs and output combinations for a logic gate or a logic circuit.
Selection IF - THEN - ELSE
Controlling program flow using comparison statements to execute alternative sections of code.
IF test THEN if_body [ELSE IF test THEN else_if_body]* [ELSE else_body] END IF
One or more optional Optional
Pseudocode
Selection statements can nest if one of the body statements is also a selection.
Selection SWITCH - CASE
Alternative to IF - THEN - ELSE statement which are considered neater and easier to follow.
SWITCH variable OF CASE value case_body [CASE value case_body]* [ELSE else_body] END SWITCH
One or more optional Optional
Pseudocode
Arithmetic operators
Often look different to operators in maths due to different symbols on the keyboards.
+ Addition
- Subtraction
* Multiplication
** Exponentiation (powers)
/ Float division
// Integer division (DIV)
% Remainder division (MOD)
Computational Thinking (CT)
Means thinking ... ★ Abstractly
Removing uneccessary detail ★ Generally
Looking for patters ★ Evaluatively
Assessing your thinking ★ Algorithmically
Step by step ★ Concurrently
More than one thing at once ★ Ahead
Preconditions ★ Procedurally / decomposition
Breaking a problem down ★ Logically
Branching and iteration
Random number generators
Used to generate random numbers to model real life scenarios. Useful functions ...
random() randint(start,stop) shuffle(sequence) sample(population,n)
Pseudocode
>>> import random >>> random.random() 0.5695470869469875 >>> random.randint(1,10) 6 >>> sequence = [1,2,3,4,5,6] >>> random.shuffle(sequence) >>> sequence [4, 6, 1, 3, 2, 5] >>> random.sample(range(1,100),5) [98, 64, 3, 34, 75]
Python
Datatypes
Computers recognise different types of data. The data type determines what processing can be performed with the variable
Integer Whole numbers
Float / Real Decimal
Boolean Two values
Character Letter, number or symbol
String Collection of characters
Type conversion
Converting one data type into another to enable different processing to be performed.
int(value) Convert to integer
float(value) Convert to float / real
bool(value) Convert to boolean
str(value) Convert to string
What is information?
DATA + STRUCTURE + CONTEXT + MEANING Data : Raw facts and figures Structure : Real world form Context : Human situation Meaning : Implied from experience
Binary numbers
Number system with only two different symbols. Used to represent data in computers because they are made from switches which can either be on or off.
128 64 32 16 8 4 2 1
0 1 1 0 1 0 0 1
In denary ... 64 + 32 + 8 + 1 = 105
Binary numbers Patterns
Remember the patterns in the bits!
Denary Binary
This shows all the binary patterns for four bits. Look carefully at the patterns in the binary numbers. The patterns repeat for five bits and higher.
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
Hexadecimal
Base 16 number system with symbols for 16 digits. We only have symbols for 0 to 9 so we have to use A to F as well.
0123456789ABCDEF Hexadecimal is used to represent binary because it's easier for humans.
1 0 1 1 0 1 0 1
B 5
Hexadecimal
Only one symbol per value, so ...
Denary Binary Hex
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
Operating system (OS)
Software used to provide a link between the hardware and the user - a 'virtual machine'. ★ Communication between hardware using
device drivers ★ Provide user interface ★ Virtual machine - a platform for
software to run ★ Manage memory ★ File management / Disk management ★ User accounts Common examples ... ★ Microsoft Windows ★ Apple Macintosh ★ Linux ★ Android ★ Apple iOS ★ UNIX
User interface
Graphical User Interface (GUI) Works on WIMP principle ★ Windows ★ Icon ★ Mouse ★ Pointer Command Line Interface (CLI) Usually a black screen with a flashing cursor. ★ Difficult to use ★ Specialist applications
Bitmap images Pixels
★ Made up from dots called pixels ★ A pixel is the smallest part of the
image that can be identified ★ Colour of each pixel represented by
an n-bit binary code
33 x 26 Bitmap Image
Bitmap images Resolution
Number of pixels per given area. The higher resolution images look sharper than lower resolution images when displayed at the same size because the pixels are smaller.
Resolution is measured in Dots Per Inch (DPI) for printers and Pixels Per Inch (PPI) for screens.
Bitmap images Colour depth
Colour of each pixel is represented by an n-bit binary code. Number of colours (colour depth) is 2n.
01 00 00 00 01 Colour palette 00 : Black 01 : White 10 : Red 11 : Green
00 10 10 10 00
00 10 11 10 00
00 10 10 10 00
01 00 00 00 01
1 bit : 21 : 2 colours 4 bit : 24 : 16 colours 24 bit : 224 : 16777216 colors 24 bit colour uses 8 bits (0-255) to represent the levels of red, green and blue in the image.
Bitmap images Metadata
Literally "Data about data". Image metadata includes ... ★ Image size (width and height) ★ Colour depth (bits per pixel) ★ Colour palette ★ Resolution (pixels per inch) ★ Date created / edited
Without metadata, the device would not be able to display the image.
Decimal prefixes
Measuring digital information in decimal
Quantity Unit Power Description
bit b 0 or 1
nybble 4 bits
byte B 8 bits
kilobyte kB 103 B 1000 B
megabyte MB 106 B 1000 kB
gigabyte GB 109 B 1000 MB
terabyte TB 1012 B 1000 GB
petabyte PB 1015 B 1000 TB
exabyte EB 1018 B 1000 PB
zetabyte ZB 1021 B 1000 EB
yottabyte YB 1024 B 1000 ZB
Binary prefixes
Measuring digital information in binary
Quantity Unit Power Description
bit b 0 or 1
nybble 4 bits
byte B 8 bits
kibibyte kiB 210 B 1024 B
mebibyte MiB 220 B 1024 kiB
gibibyte GiB 230 B 1024 MiB
tebibyte TiB 240 B 1024 GiB
pebibyte PiB 250 B 1024 TiB
exbiyte EiB 260 B 1024 PiB
zebibyte ZiB 270 B 1024 EiB
yobibyte YiB 280 B 1024 ZiB
Pseudocode
A general non-specific algorithm language which uses words and symbols ...
Structured English
A general non-specific algorithm language which uses words only ...
Flowcharts Symbols
Flowcharts use different shaped symbols for different actions ...
Flowcharts Sequencing
Doing one thing after another ...
Flowcharts Selection
Doing one thing or another depending on the outcome of a decision.
Flowcharts Repeat ... Until
Complete a sequence of tasks until a condition is met.
Flowcharts While / For
While a condition is true, carry out a sequence of tasks.
Compression
Reducing the size of a file whilst maintaining as much content in the file as necessary for the application Compressed files ... ★ Take up less storage space ★ Require less bandwidth for
transmission over a network ★ Transfer in shorter time over a
networks
Compression Lossy
Permanently remove detail from a file to reduce its size. Used for ... ★ Images ★ Sound ★ Video ... as removal of some detail doesn't affect human perception of the media.
Compression Lossless
Does not remove any detail from the file so when it decompressed, it is the same as the original. Used for ... ★ Text files ★ Documents ★ Software / binary files ★ Some image types ★ Some sound types
Compression Run Length Encoding (RLE)
Replaces runs of similar data a single data item and the number of times it appears ...
WWWBGTTTTJJWWWWBBDDDDDDUUJJJJ ↓
3W1B1G4T2J4W2B6D2U4J Results in only a slight reduction in file size.
Huffman trees
Dictionary encoding where each letter is represented with a binary code. The more common the letter, the shorter the code used to represent it, thus saving space. E; 1 B; 010 R; 011 T; 000 _; 001
0 0 0 0 1 1 1 1 0 0 1 0 1 0 1 1
T R E E _ B E E
Search algorithm Linear search
Sequential search, starts at the beginning moving one item at a time. Suited to an unordered list of items.
Worst case - not in the list Best case - first item in list
Search algorithms Binary search
Divide and conquer algorithm. Check middle item, discard half list and continue. List has to be ordered.
Worst case - not in list Best case - middle item
Sorting algorithms Bubble sort
Compares adjacent items and swaps if necessary. Continues until no more swaps or last one item left in unordered list.
Shows one pass
Sorting algorithms Insertion sort
Puts each item into the sorted portion of a list in the correct place.
Sorting algorithms Merge sort
Breaks an unordered list into parts and builds it back up again in order.
Sound Analogue vs digital
Sound waves are analogue (continually varying). Computers can only store sounds digitally (using binary).
Sound Sampling rate / frequency / interval
The frequency (samples per second, units Hz) at which the amplitude of the analogue wave is measured. ★ 8000Hz (8kHz) - Telephone ★ 16000Hz (16kHz) - VoIP ★ 44100Hz (44.1KHz) - CD quality ★ 48000Hz (48KHz) - Professional ★ 96000Hz (96KHz) - Bluray / DVD
Increase sampling frequency
Analogue wave sampled more often and is
better quality
More storage space required to store more
samples
Sampling interval is the gap (in seconds) between each sample.
Sound Sampling resolution
Number of bits (n) used to store the size of each sample. Maximum amplitude of analogue wave is broken down into 2n possible values. ★ 4 bits - 16 values ★ 16 bits - 65536 values ★ 24 bits - 16777216 values
Increase sampling
resolution
Quieter sounds can be sampled and sampled
wave is closer to original
More storage space required to store more
samples
Sound Bit rate
Number of bits used to represent one second of sampled sound. Given by ... bit rate
= sampling frequency
x sample
resolution x channels
Measured in kilobits per sec (kbps) ★ 32kbps - speech ★ 192kbps - medium quality streaming ★ 320kbps - high quality streaming
Strings
Collections of characters.
Strings are surrounded by quotation marks (which must match). Each character in the string is located using its index.
0 1 2 3 4
H E L L O
Notice that the indices start at 0.
String slicing
Extracting a portion of a string using index values.
>>> message = 'Hello' >>> message[0] 'H' >>> message[4] 'o' >>> message[5] index out of range error >>> message[3:] 'lo' >>> message[:4] # end is index+1 'Hel' >>> message[1:3] 'el'
Python REPL
String methods
Ways of finding out about or altering how strings display.
>>> message = 'hello World' >>> len(message) 11 >>> message.count('l') 3 >>> message.lower() 'hello world' >>> message.upper() 'HELLO WORLD' >>> message.capitalize() 'Hello world' >>> message.title() 'Hello World'
Python REPL
Defensive design
Ensures programs function correctly ★ Anticipate 'misuse' ★ Authenticate the user ★ Keep code well maintained ★ Reduce errors through testing
Well maintained code
Makes it easy for programmers to fix errors and add features to the program. ★ Comments ★ Indentation ★ Suitable variable and sub-program
names which reflect their purpose ★ Prefer local scope variables over
global scope
Analysis
★ Resources ★ Decomposition ★ Strategies ★ Success criteria ★ Defensive design considerations ★ Real world utility considerations
Design
★ Variables and data structures ★ User interface ★ Testing plan ★ Robustness ★ Real world utility ★ Scope
Implementation
★ Techniques ★ Testing during development ★ Coding standards ★ Use of procedures and functions ★ Link to design / analysis
Testing / evaluation
★ Testing plan ★ Range of test data ★ Evidence of testing ★ Links to success criteria ★ Corrective maintenance ★ Link back to original problem
Central Processing Unit (CPU)
Processes data and instructions. Central processing units often have multiple cores e.g. Dual core (2) or Quad core (4). Multicore processors are more efficient because the cores can be given jobs to perform simultaneously.
Clock speed
Rate at which the Central Processing Unit can perform operations, e.g. 4GHz - this means the CPU can perform 4 billion operations per second. ★ Clock speed has implications for
power usage ★ Clock speed has implications for heat
generation It is often more efficient to use a multicore processor.
Cache memory
Volatile memory located within the CPU chip and generally holds less data than primary storage (RAM). Manufacturing costs higher than RAM but is faster. Typical capacities from 512kB to 2MB per processing core. Slower than registers but faster than RAM and holds regularly used data. A bit like a handbag containing essential items.
Computer architecture
Von Neumann Architecture This is the design of most CPU. Both the program and the data is loaded into the same memory. Harvard Architecture Programs and data are held in separate memories. Often used in embedded systems (microcontrollers) where the program does not change.
Control unit
Coordinates the actions of the CPU. It sends out control signals to other parts of the CPU and controls data flow inside the CPU. The Control Unit decodes and executes instructions following the Fetch - Decode - eXecute (FDX) cycle.
Arithmetic and Logic Unit (ALU)
This is responsible for all the arithmetic and logical operations in the CPU. E.g., Add, Subtract, divide, multiply, And, Or, Not, binary shifts. The ALU contains the Accumulator.
Program counter (PC)
This holds the MEMORY address (location) of the next instruction to be executed.
Accumulator (ACC)
This stores the results of any calculations performed by the Arithmetic and Logic Unit (ALU).
Memory Data Register (MDR) Memory Buffer Register (MBR)
Acts as a buffer, a storage place for data that is "on its way" to somewhere else. It holds data which has been requested by the CPU from the memory or data which the CPU has requested is written to memory.
Registers
Registers are very fast memory locations on the CPU which help it to keep track of what it's currently doing. Register store data and the instructions. The main registers are the ... ★ Memory Data Register (MDR) ★ Memory Address Register (MAR) ★ Program Counter (PC) ★ Accumulator (ACC)
Memory Address Register (MAR)
The memory address register – This holds the address (location of) the place in memory that will be read during the FETCH of the CPU.
Fetch (Decode) Execute Cycle
Each CPU core carried this process out billions of times per second!
★ FETCH : [PC] → [MAR]
[Memory] → [MDR] [PC] → [PC] + 1
★ DECODE : Decode instruction ★ EXECUTE : Perform instruction
CPU Performance
Depends on ... ★ Clock speed ★ Number of processing cores ★ Size and type of cache
Graphics Processing Unit (GPU)
Special circuits designed to deal with high demand graphics and video processing. Relieve load from the main CPU. Can be used to perform extra processing tasks if the CPU requires 'help'.
Packet transmission
Data is sent through a network in packets. Each packet contains metadata which describes it.
Packet switching
Data is sent through a network in packets. Each packet can take a different route but the data is recombined at its destination.
Rules are given in the Transmission Control Protocol / Internet Protocol (TCP/IP) suite of protocols.
Common network protocols
TCP/IP is most important but there are many, many others.
TCP/IP Transmission Control Protocol
IP Internet protocol
HTTP Hyper Text Transfer Protocol.
HTTPS Secure HTTP
FTP File Transfer Protocol
POP3 Post Office Protocol V3
IMAP Internet Message Access Protocol
SMTP Simple Mail Transfer Protocol
UDP User Datagram Protocol
TCP/IP network layers
Data passes through layers on its way to and from clients and servers.
APPLICATION
4 Application Layer
Data to files and vice versa
3 Transport Layer
Flow of packets, error checking
2 Network Layer
Making connections, directing packets
1 Link Layer
Passing signals through a network
CABLES
Anticipate misuse
Input sanitisation Remove unwanted characters from input strings before processing Input validation Check input against criteria ★ Range check ★ Presence check ★ Format check ★ Type check ★ Lookup check ★ Length check ★ Check digit
Exception handling
Use TRY.EXCEPT to handle unexpected errors. The EXCEPT part will only run if the TRY part fails with a runtime error.
while True: try: number = int(input('Number : ')) break except: print('That is not a number!')
Python
Verification
Using double entry, manual checking or email to ensure that data is entered as intended. Does not ensure that the data is correct.
Impact of computers on the World
Ethical Issues considered right or wrong by society Legal Issues considered right or wrong in the eyes of the law. Cultural The effect on groups of people with particular beliefs, practices or languages. Environmental The impact on the natural world.
Stakeholders
A person or group of people who have an interest or who are affected by a particular situation. ★ Company owner ★ Employees ★ Shops ★ Customers ★ Hardware / software supplier ★ Local community
Ethical considerations Privacy
Issues surrounding storage or access to personal data through computer systems ... ★ Personal information held on website
databases ★ Social media ★ Cloud computing ★ DNA profiling ★ National Identity cards ★ CCTV ★ Electronic tracking
Ethical considerations Censorship
When some organisation controls content on or access to the Internet. Censorship is used to ... ★ Influence peoples views of the world ★ Protect people (such as children)
from pornography, gambling and other inappropriate websites.
Ethical considerations Surveillance
Where an organisation monitors the behaviour of a person or a group of people ★ Location (GPS / phone tracking) ★ Movement (CCTV) ★ Internet activity (ISP)
Ethical considerations Effect on wellbeing
★ Constant new technology / upgrading ★ Peer pressure ★ Overuse of smartphones / tablets ★ 'Always on' culture - no breaks ★ Movement away from social interaction
Ethical considerations Impact of social media
Keeping in touch Easy to keep in touch with all your friends and family. Cyberbullying Using social media to deliberately cause emotional harm to someone else. Trolling Deliberately causing arguments online for their own amusement, to cause offence or to gain attention.
Ethical considerations Health problems
★ Excessive screentime ★ Eye strain ★ Lack of exercise ★ Repetitive Strain Injury (RSI) ★ Posture / back problems ★ Obsessions / addiction ★ Poor diet resulting from excessive
time spent gaming
Cultural considerations Recreation
★ Selfie culture ★ Viral videos ★ Blogging ★ On demand music / video ★ Video calling
Cultural considerations Digital divide
The gap between people who have access to digital equipment and people who don’t. It might be because ... ★ Lack of access to internet ★ Unable to afford it ★ Low IT literacy
Cultural considerations Changing face of business
eCommerce ★ No need to maintain high street store
which saves money ★ Target a wider audience around the
world. ★ Customers can buy from any company
around the world Teleworking ★ Flexible working hours ★ Not tied to one location ★ Can work from home
Cultural considerations Changing face of education
★ Interactive whiteboards ★ Virtual learning environments ★ ebooks ★ Computerised administration ★ Distance learning ★ Independent learning ★ MOOCs / access to elite educational
establishment from anywhere in the world
Cultural considerations Health
★ Online access to patient records ★ 'Doctor Google' ★ Medical technology ★ Remote surgery ★ DNA profiling ★ Health insurance
Environmental impact
The impact of computers and computer systems on the environment. ★ Energy consumption ★ Heat generation ★ e-waste ★ Sustainability ★ Earths resources / mining ★ Recycling
Legislation Data Protection Act 1998
S – keep data SECURELY L – keep data LAWFULLY E – Only within the EU E – Not EXCESSIVE data P – Only for PURPOSE intended F – Keep data FAIRLY L – Don’t keep data for LONGER U – Keep data UP TO DATE
Legislation Freedom of Information Act 2000
This is a law that gives you the right to access information held by public authorities E.g. government, health service, schools, police, courts
Legislation Computer Misuse Act 1990
Three levels of computer crime ... ★ Unauthorised access to computer
material ★ Unauthorised modification of computer
material ★ Unauthorised access to a computer
system with the intent to commit crime.
Legislation Copyright Designs & Patents Act 1998
This law protects people’s original work from being used without their permission ★ Intellectual property ★ Books ★ Films ★ Music ★ Software ★ Ideas Issues ★ Internet ★ Illegal file sharing ★ Copying for personal use
Creative Commons (CC)
A software license that allows the public to have permission to share, remix, develop and distribute work under certain conditions.
Attribution
Attribution share-alike
Attribution no-derivatives
Attribution non-commercial
Attribution non-commercial share-alike
Attribution non-commercial no-derivatives
Ethical considerations 10 Commandments of Computer Ethics
Thou shalt ... ★ not use a computer to harm other people ★ not interfere with other people's
computer work ★ not snoop around in other people's
computer files ★ not use a computer to steal ★ not use a computer to bear false witness ★ not copy or use proprietary software for
which you have not paid (without permission)
★ not use other people's computer resources without authorization or proper compensation
★ not appropriate other people's intellectual output
★ think about the social consequences of the program you are writing or the system you are designing
★ always use a computer in ways that ensure consideration and respect for your fellow humans