Вы находитесь на странице: 1из 64

Authentication CAPTCHA

Part of Defensive Design, authentication C​ompletely


confirms the identity of the user before A​utomated
they are allowed to access the system. P​ublic
T​uring tests to tell
★ CAPTCHA C​omputers and
★ Password H​umans
★ Biometric A​part

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 Biometrics

Strong passwords have ... Uses behavioural or physiological


qualities to identify you.
★ Mixture of upper case, lower case,
numbers and symbols Behavioural
★ Non-consecutive character types
★ Combinations of unrelated words ★ Keystrokes
★ Mouse movements
Passwords authenticate based on the fact ★ Signatures
that you are the only one who knows it! ★ Voice
★ Body position / gait

Physiological

★ Fingerprint
★ Hand
★ Iris / Retina
★ Face
★ DNA

Consider the ethical issues surrounding


the use of personally identifiable data.
Subprograms / subroutines Decomposition

Used to avoid code repetition, structure Breaking a larger problem apart in order
code properly and make code more to make it easier or more straightforward
readable. to solve.

Variables inside subroutines are ​local Can often reveal patterns which allow
(unless specified as ​global​) and are only previous solutions to be applied to new
available to the subroutine. situations.

Procedures Functions

Subprograms which ​sometimes​ take Subprograms which ​always​ take parameters


parameters but ​never​ return values. and ​always​ return a value to the callee.

Used mainly to structure code and avoid Used to hide a mathematical or logical
reptition of code in a whole solution. operation behind a simple interface.
Arrays One dimensional array

Allow data to be collected, accessed and Behaves like a single ​list​. Each item is
manipulated ​under one variable name​. Each accessed using its index.
item in an array is accessed using its
index. 0 1 2 3 4
names Mark Fred Alice Leanne Tracy
Technically, arrays are fixed length data
structures which need to be declared
before they are used. For instance, to >>> names[2]
create a 7 element array, diggers ... 'Alice'
Python REPL
ARRAY diggers(7)
Pseudocode

Two dimensional array List methods

Behaves like a ​table​. Each value can be Enable operations on lists. Vary with
accessed using a combination of its row programming languages but in Python ...
index followed by its column index.
list​.append(​item​)
scores 0 1 2 3 4 list​.insert(​position​,​item​)
list​.sort()
0 5 2 4 7 2 list​.pop()
1 2 3 7 6 4 list​.count(​item​)
list​.reverse()
2 6 2 1 4 6 list​.index(​item​)
separator​.join(​list​)
3 8 4 9 2 4
Python
4 4 5 2 7 8

>>> scores[3][2]
9
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 Characters

Converting ASCII code to single Letters, numbers and symbols are


characters and characters to ASCII codes. represented with a binary code through
use of an encoding table. Encoding tables
>>> chr(70) don't describe how the characters should
'F' be displayed.
>>> ord('F')
70 ASCII
Python REPL
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 Media Access Control (MAC) address

A set of agreed standards designed to Every networkable device ​in the world​ has
make communication fast, reliable and a different MAC address used to uniquely
error free. identify the device. 48 bit binary code
written in hexadecimal (makes it easier
De Jure to read / recognise).

Standards which are governed by written / 11110000-11011110-11110001-10010100-11010010-01101010

published rules which everyone adheres


to. ↓
De Facto F0-DE-F1-94-D2-6A
Standards which are accepted because they Used by switches to direct data to the
are most common. correct devices in a network.

MAC addresses are like house numbers -


they identify individual devices.

Internet Protocol (IP) address The Internet

Used by routers to send data across a A publically accessible network of


network. IP addresses are hardware networks - the largest WAN.
independent (unlike MAC addresses). IP
addresses can be static (stays the same) ★ A vast, global collection of
or dynamic (changes regularly). hardware, computers, cables
satellites.
01000000.11101001.10100111.01011110 ★ No central management.

↓ ★ NOT the same as the World Wide Web

64.233.167.94
IP Addresses are like postcodes and give
the location of a computer / group of
computers.
The World Wide Web (WWW) Unform Resource Locator (URL)

A collection of websites hosted on Proper name for a website address.


web-servers accessed on the Internet
using the HTTP / HTTPS protocols.

Domain Name System (DNS) The Cloud

Maps domain names (website addresses) to ★ Data is hosted in 'server farms' all
IP addresses so you don't have to over the world
remember the IP address of your favourite ★ Massive 'redundancy' makes data
website. 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 Check digits
Parity bit
A digit added to the end of a sequence of
numbers or characters which is calculated Most significant (leftmost) bit in a
from numbers or characters in the binary string is ​toggled ​to enforce
sequence. Used to check for errors. 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 p
​ arity

0 1 0 1 1 0 0 0
Converted to ​ODD ​parity

Check digits ARQs


Checksum
Automatic Repeat Request. This is an
Value calculated from the other values in error control mechanism for data
the number. Calculated using a hashing transmission which uses ​ACK​nowledgements
algorithm. and timeouts to achieve reliable data
transmission over an unreliable service.
★ ISBN number
★ MD5 hash
Cookies Parallel and serial transmission

Simple text files which websites store on Parallel : data sent simultaneously
your computer when you visit them. Serial : data send individually

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?

Simplex, half-duplex, full-duplex Caeser cipher

Direction of transmission and whether Rotating shift cipher used in simple


transmission can occur in both directions types of encryption.
at once.

Caeser Cipher
Key of 6
Comparison operators Boolean operators

A comparison operation compares two Logical operator used to combine multiple


values (the operands) and returns either True / False conditions to form more
True or False dependant on the comparison complex conditions.
being performed
x ​AND​ y Returns True if both x and y are True,
== Is the same as False otherwise.

<> or != Is not the same as x ​OR​ y Returns True if either x or y or both x


and y are True, False otherwise.
< Is less than
NOT​ x Returns True if x is False and False if
<= Is less than or equal to x is True.

> Is greater than

>= Is greater than or equal to


Utility software Utility software
Degfragmentation Backup / archiving

Reorganises files on the surface of hard Safeguards data from accidental loss,
disk drives to make them 'contiguous' - corruption or theft.
in order. Provides faster file access.
Not used for SSD as extra write Full
operations shortens the lifespan of the
drive. Backup of every file is taken
Takes a long time to complete

Incremental

Only files which have changed


Less storage space required

Utility software Utility software


Compression Encryption

Uses special algorithms to reduce size of Scrambles sensitive data using a 'key'
files. (usually a password) to stop other people
/ computers reading the data.
Helps to save storage space and also
speed up data transfer.

Standard file types are ZIP, RAR.


Open source software Proprietary / closed source
software
Source code (program code) is freely
available and compiled 'binaries' can be Source code (program code) is compliled
downloaded for free. Anyone can modify to keep it secret and not released.
the source code to create their own Often, though not always, paid software.
'forks' and share.
★ Microsoft Office
★ Apache web server ★ Adobe Creative Suite
★ Google Chrome ★ Apple iOS
★ Android OS
★ Firefox browser
★ VLC media player
★ GIMP (Graphics software)
★ Libre Office
★ FileZilla

Program languages Programming languages


Generations Levels

Computers understand binary (machine LOW​ Level


code) whereas humans understand formal
languages (English like). ★ 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 Language translators
Assembler Compiler

Translates mnemonic based assembly code Translates the whole of the source code
into machine code all at once. into object code (machine code) which is
then executed by the processor.

Each processor type has its own dedicated


assembler. ★ Compilation happens once
★ Errors generated at compilation
★ Compiler is not required again
★ Object code runs quickly
★ Examples : C++, VB

Language translator Integrated Development Environment


Interpreter (IDE)

An interpreter executes the instructions ★ Code editor


in the source code directly one line at a ★ Run-time environment
time rather than converting it to object ★ Code navigation tools
code and asking the processor to execute ★ File navigation tools
it. ★ Breakpoint / stepping tools
★ Debugging tools
★ Error diagnosis
★ Auto-documentation

★ Interpreter required every time


★ Interpreter halts execution on errors
- useful for debugging
★ Source code runs slowly
★ Examples : Python, PHP, Javascript
Geany IDE
Computer system Hardware

Any machine that has ... The physical components of a computer


system that you can touch.
★ I​nput
★ P​rocessing ★ Motherboard
★ S​torage ★ CPU
★ O​utput ★ Memory
★ Monitor
Computer systems were created to process ★ Printer
data faster and more accurately than ★ Power supply
humans. ★ Hard disk drive
★ Optical drive
★ Graphics card

Software Embedded system

The applications / programs that a Computer systems built into another


computer system runs. device They are single printed circuit
boards that include the processor,
★ Operating system memory, input and output interfaces. For
★ Word processor example ...
★ Presentation software
★ Web browser ★ Digital camera
★ Virus checker ★ Microwave
★ Washing machine
★ Engine management system
★ Traffic light

Embedded systems are often more efficient


that general purpose computers because
they have less components and are
designed to perform just one task.
Local Area Network (LAN) Wide Area Network (WAN)

A network of computers in a small A WAN connects LANs from different


geographical area (building, office, geographical areas. The hardware in a WAN
site). The hardware is owned by the is owned by different organisations.
organisation.
Commonly called an 'internet'.
Enables sharing of ...
The most common WAN is the ​Internet​ (note
★ Files the capital 'I').
★ Printers / Storage
★ Internet connection

Centralised account management

Performance of networks Network Interface Controller (NIC)

Affected by ... A hardware card built into a motherboard


or sometimes as a separate card that
★ Bandwidth allows the computer to connect to a LAN
★ Number of users sharing connection via wired or wireless connection.
★ Connection method (wired, wireless,
optical fibre)
★ Type of hardware used
★ Topology (layout)
Network switch Router / Router switch

Intelligent device with multiple NICs (32 Device responsible for transmitting (or
or 64) which transmit data between routing) data between networks based on
computers based on their Media Access their Internet Protocol (IP) address.
Control (MAC) addresses.
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 Wireless (Wi-Fi)

Ethernet​ (CAT5) ★ Radio frequency transmission on


2.4GHz or 5GHz channels
★ Stranded copper
★ "Twisted pair"
★ Short distance
★ Home / office

Coaxial

★ Single copper
★ Shielded to prevent interference
★ Short distance

Fibre Optic
★ Overlapping channels cause
★ Plastic / glass interference
★ Transmit data with light ★ Requires Wireless Access Point (WAP)
★ Long distance / Wireless switch
★ Does not suffer from interference ★ Implemented using security (WPA, WPA2
or TKIP)
Client-server network Peer-to-peer network

Network managed by a server which handles All machines are 'equal'. Users, files
logins, file sharing, permissions. All and permissions are managed at the
other devices are clients (wired or individual machines.
wireless).

★ Home networks
★ All machines equal
★ Mainly used in businesses ★ No centralised managment
★ Relience on server
★ Central managment

Star network topology (layout) Mesh network topology (layout)

Network is physically laid out in a star Each device is connected directly to each
shape. All devices connected together other device. Mainly implemented using
using a single switch or hub. Wireless rather than cable.

★ Cheap
★ Reliable ★ New technology
★ Relience on switch ★ Fastest routes used
Virtual network Benefits of networking

A private, software based network using Sharing resources


existing physical hardware by reserving
resources. ★ Printers
★ Internet connection
Virtual Private Network (VPN) ★ Files
★ Communication
Secure virtual network used for ★ Centralised management
transferring files / data securely.
Network policies Penetration testing

A good network policy should advise ... White hat hackers employed to test for
vulnerabilities in a computer system and
★ Regular security testing report back to company.
★ Insistence on strong passwords
★ Regular password updates
★ User access levels
★ Antivirus / firewall software
★ No removable media
★ Encryption

Network forensics Network security methods

Investigating logs, capturing data ★ Updated software / patches


packets, inspecting files to locate ★ Authentication
network vulnerabilities. ★ Encryption
★ Passwords
★ Firewalls
★ Proxy servers
★ MAC address filtering
★ Secure Socket Layer (SSL)
★ Transport Layer Security (TLS)
★ Anti-malware software
★ Physical security
Network security attacks Malware

Types of security attacks ... Types

★ Passive ★ Virus
★ Active ★ Worm
★ Insider ★ Trojan
★ Brute force
★ Denial-of-service Actions

★ Deleting / modifying files


★ Scareware
★ Locking files (ransomware)
★ Spyware
★ Rootkits

Social engineering SQL Injection

Gaining access to a computer resource by Using a special language called


tricking people. Structured Query Language (SQL) to trick
a website database into revealing data.
★ Telephone scams
★ Phishing The SQL code is either included in the
★ Pharming website address or typed in web forms.
★ Shoulder surfing
Very hard to detect but incredibly
powerful hacking tool.

Database must be very secure.


Databases Databases
Structure CREATE TABLE

Persistent, organised store of data Structured Query Language statement used


organised using tables, record and to create a table.
fields.
List each field followed by its data type
Fields and indicate whether it is the primary
key for the table.
id name dob dept pay
1 John 15.01.75 J2 19000
CREATE TABLE​ employees
Records 2 Karen 27.07.90 J5 27000 (
id ​INTEGER​ ​PRIMARY KEY
3 Bert 12.08.65 Z1 26000
name ​TEXT
PK dob ​DATE
dept ​TEXT
pay ​INTEGER
Each record has a Primary Key (PK) which )
is used to identify it in the table. Each SQL
field can only have one data type but
each record can have a mix of data types.

Databases Databases
INSERT INTO UPDATE

Structured Query Language command used to Used to update records by searching for a
insert data into a table ... record using the value in one of its
field and specifying a new value for its
INSERT INTO​ employees ​VALUES fields.
(1,'John',15.01.75,'J2',19000)
(2,'Karen',27.07.70,'J5',27000) Update Karens pay
(3,'Bert',12.08.65,'Z1',26000)
UPDATE ​employees
SQL SET​ salary = 29000
WHERE​ id = 2
You can also insert individual fields SQL
(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 Databases
SELECT SELECT WHERE

Retrieve data from the database by Filter data from a database based on
searching for values in given fields. criteria / patterns

All details for all employees Employees with pay > 20000
SELECT​ * ​FROM ​employees ​ ROM ​employees
SELECT​ name F
WHERE​ pay > 20000
SQL
SQL
Employees
Employees with pay > 20000 in dept J5
SELECT​ name ​FROM ​employees
SELECT​ name ​FROM ​employees
SQL WHERE pay > 20000
AND dept = 'J5'
Employees and their pay
SQL
SELECT​ name, pay ​FROM​ employees
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 ​ASC​ending or


DESC​ending 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 Variables / variable names

Storing a value in the computers memory A value in the computers memory which can
and labelling it with a 'name' to allow change during program execution.
you to make reference to it later in your
code. Variables are given a name to allow you
to make reference to them during program
>>> name = 'Tarquin' operation.
>>> widgets = 12
>>> price = 9.62 There are rules to variable names :
>>> paid = False
Python REPL ★ Only letters, numbers and underscores
★ Can't start with a number
name ← 'Tarquin'
★ Cannot be a keyword from the
widgets ← 12 programming language
price ← 9.62 ★ Cannot contain spaces
paid ← False
Pseudocode

The assignment operator is the single


equals sign (=). This does not mean 'is
the same as' ...

Constants Input

Values stored in the computers memory Asking the person using the computer to
which are not changed during program either type something in using the
execution. keyboard or select something using a
mouse or get a signal from a sensor.
Constants allow ...
>>> name = input('Enter your name : ')
★ Mathematical values (like π) to be Enter your name : ​Mark
represented in the code as a name >>> print(name)
rather than a value. Mark
★ Values to be referenced in the code Python
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
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 Binary numbers
Addition Arithmetic shifts

Rules Left shift multiplies by 2

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) Right shift divides by 2

(Just like left and right shifts in


denary multiply and divide by 10!)

Binary numbers Binary numbers


Overflow Negative numbers

If a binary addition or a left shift Using two's complement method. For


results in a number which is too big to example, to represent -28 ...
fit in the number of bits available.
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 Testing strategies

(Part of Defensive Design) (Part of Defensive Design)

Syntax errors Unit testing

Caused by mistakes in the grammar of the Individual routines are tested


language - make sure you type your code independently (white or black box).
correctly!
Integration testing
Runtime errors
Routines are combined together to make
Use validation including try-except sure they interact correctly
routines to trap unexpected errors.
System testing
Semantic / logic errors
Make sure the system solves the original
Check the operation of the code manually problem
through trace tables.
Acceptance testing

Check whether software is suitable for


client and delivery.

Test data Black box and white box testing

(Part of Defensive Design) (Part of Defensive Design)

Boundary data A ​white box​ test involves the tester


(normally the programmer) testing the
Values which are used to check the inner units, combinations of units or the
and outer edges of validation ranges. entire system with complete knowledge of
the underlying code.
Normal data
A ​black box​ test involves the tester
Values which lie within the edges of (often not a programmer) testing
validation ranges. combinations of units or the whole system
without any awareness of the underlying
Erroneous data code. Can also happen during acceptance
testing.
Values which should be rejected outright,
for instance, outside range or wrong data
types.
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 Sensors

Manual input of data Automatic input of data

★ 2D / 3D scanners ★ Light
★ Barcode readers ★ Temperature
★ Quick Response (QR) code readers ★ Magnetic field
★ Digital cameras ★ Gas
★ Keyboards ★ Pressure
★ Mice ★ Moisture
★ Touch screen ★ Humidity
★ Interactive whiteboards ★ pH
★ Microphones ★ 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) Read Only Memory (ROM)

Volatile primary storage which holds the Non volatile - does not need power to
data and instructions / programs hold it's data.
currently executing​ and requires power to
retain it's data. Holds the boot up program used when the
computer first starts (boot strap) known
The 'random' in RAM means that the memory as the BIOS (basic input output system).
can be accessed directly rather then
sequentially (one after another). Can only be read from, not written to.

RAM can be read from or written to. Can be 'flashed' (reprogrammed) using
special software or hardware.

Basic Input Output System (BIOS) Virtual memory

Instructions held in ROM which tell the An area on the hard disk used as memory.
computer how to boot up correctly. Used when RAM is too small to deal with
the amount of instructions. Effects the
Performs self checks of memory and check performance of the computer because the
which hardware is present loading certain access time on the hard disk drive is
device drivers. slow.
Iteration / Repetition Iteration / Repetition
FOR - NEXT WHILE

Counter controlled​ loop will work through Condition controlled​ loop which checks a
every value in an 'iterable' object condition at the start and only executes
(range, string, list) setting a loop it's body if the condition is ​ ​TRUE​ ​.
variable to each value in the iterable in
turn. WHILE ​condition
​while_body
FOR​ ​value​ ​IN​ ​iterable Pseudocode
​for_body
Pseudocode

The for_body tends to use the value from


the iterable in it's operations.

Iteration / Repetition Iteration / Repetition


REPEAT-UNTIL DO-WHILE

Condition controlled​ loop which checks a Condition controlled​ loop which checks a
condition at the end of the body and only condition at the end of the body and only
executes it's body again if the condition executes it's body again if the condition
is ​ FALSE ​. is ​ ​TRUE​ ​.

REPEAT DO
​repeat_body ​do_body
UNTIL​ ​condition WHILE​ ​condition
Pseudocode Pseudocode
Types of storage Hard Disk Drive (HDD)

Primary storage​ (mostly volatile) Internal storage device. Made from


magnetised metal 'platten' - data is
★ CPU registers written and read using an arm.
★ 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)


★ High capacity
★ Magnetic tape ★ Fragile
★ Cheap / MB
★ Long life

Solid State Drive (SDD) Flash memory

Internal secondary storage devices with Solid-state memory used as low cost
no moving parts. secondary storage in portable devices and
as removable memory, e.g.
★ Much faster than HDD
★ More robust ★ USB memory stick / flash drive
★ Expensive / MB ★ Secure Digital Card (SD)
★ Don't slow with fragmentation of ★ Micro SD Card
files
Optical disk Magnetic tape

Data is read and written using low power Single length (>250m) of plastic tape
laser. Technique varies between discs. covered in magnetic particles.

★ Compact Disc (CD) 700MB ★ Very low cost / MB


★ Digital Versatile Disc (DVD) 4.7GB ★ Very slow read / write speeds
★ Blu-Ray 25GB ★ Used for archive / backup
★ Sequential (in order) access

File handling Assessing choice for storage

Store data in text or binary format on Consider ...


secondary storage.
★ Reliability
open Create a file handle to allow access to ★ Speed
the file through a name ★ Capacity
★ Durability
read Retreive from a file ★ Cost
★ Portability
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.
Logic gates Logic gates
AND OR

BOTH inputs need to be ON (1) for the At least one inputs need to be ON (1) for
output to be ON (1) output to be ON (1)

A B Q A B Q
0 0 0 0 0 0
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1 1 1 1

Logic gates Logic gates


NOT Truth table

The output is opposite to the input A table that contains all of the inputs
and output combinations for a logic gate
or a logic circuit.

A Q
0 1
1 0
Selection Selection
IF - THEN - ELSE SWITCH - CASE

Controlling program flow using comparison Alternative to IF - THEN - ELSE statement


statements to execute alternative which are considered neater and easier to
sections of code. follow.

IF​ t ​ est​ ​THEN SWITCH​ ​variable​ ​OF


​if_body ​CASE​ ​value
[​ELSE IF​ ​test​ ​THEN One or more optional ​case_body
​else_if_body​]* [​CASE​ ​value One or more optional
[​ELSE Optional ​case_body​]*
​else_body​] [​ELSE Optional
END IF ​else_body​]
END SWITCH
Pseudocode
Pseudocode
Selection statements can ​nest​ if one of
the body statements is also a selection.
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) Random number generators

Means thinking ... Used to generate random numbers to model


real life scenarios. Useful functions ...
★ Abstractly
Removing uneccessary detail
random()
★ Generally
randint(​start​,s
​ top​)
Looking for patters
shuffle(​sequence​)
★ Evaluatively
sample(​population​,​n)​
Assessing your thinking
★ Algorithmically Pseudocode
Step by step
★ Concurrently >>> import random
More than one thing at once >>> random.random()
★ Ahead 0.5695470869469875
Preconditions >>> random.randint(1,10)
★ Procedurally / decomposition 6
Breaking a problem down >>> sequence = [1,2,3,4,5,6]
★ Logically >>> random.shuffle(sequence)
Branching and iteration >>> sequence
[4, 6, 1, 3, 2, 5]
>>> random.sample(range(1,100),5)
[98, 64, 3, 34, 75]
Python
Datatypes Type conversion

Computers recognise different types of Converting one data type into another to
data. The data type determines what enable different processing to be
processing can be performed with the performed.
variable
int(​value​) Convert to integer
Integer Whole numbers
float(​value​) Convert to float / real
Float / Real Decimal
bool(​value​) Convert to boolean
Boolean Two values
str(​value​) Convert to string
Character Letter, number or symbol

String Collection of characters

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 Binary numbers
Patterns
Number system with only two different
symbols. Used to represent data in Remember the patterns in the bits!
computers because they are made from
switches which can either be on or off. Denary Binary This shows all the
0 0000 binary patterns for
128 64 32 16 8 4 2 1 1 0001 four bits.
2 0010
0 1 1 0 1 0 0 1
3 0011
Look ​carefully​ at the
patterns in the binary
4 0100
In denary ... 64 + 32 + 8 + 1 = 105 numbers.
5 0101
6 0110 The patterns repeat for
7 0111 five bits and higher.
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111

Hexadecimal Hexadecimal

Base 16 number system with symbols for 16 Only one symbol per value, so ...
digits. We only have symbols for 0 to 9
so we have to use A to F as well. Denary Binary Hex
0 0000 0
0123456789ABCDEF 1 0001 1
2 0010 2
Hexadecimal is used to represent binary 3 0011 3
because it's easier for humans. 4 0100 4
5 0101 5

1 0 1 1 0 1 0 1 6 0110 6
7 0111 7

B 5 8
9
1000
1001
8
9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
Operating system (OS) User interface

Software used to provide a link between Graphical User Interface​ (GUI)


the hardware and the user - a 'virtual
machine'. Works on WIMP principle

★ Communication between hardware using ★ Windows


device drivers ★ Icon
★ Provide user interface ★ Mouse
★ Virtual machine - a platform for ★ Pointer
software to run
★ Manage memory Command Line Interface​ (CLI)
★ File management / Disk management
★ User accounts Usually a black screen with a flashing
cursor.
Common examples ...
★ Difficult to use
★ Microsoft Windows ★ Specialist applications
★ Apple Macintosh
★ Linux
★ Android
★ Apple iOS
★ UNIX
Bitmap images Bitmap images
Pixels Resolution

★ Made up from dots called ​pixels Number of pixels per given area. The
★ A pixel is the smallest part of the higher resolution images look sharper
image that can be identified than lower resolution images when
★ Colour of each pixel represented by displayed at the same size because the
an ​n-bit​ binary code pixels are smaller.

33 x 26 Bitmap Image
Resolution is measured in Dots Per Inch
(DPI) for printers and Pixels Per Inch
(PPI) for screens.

Bitmap images Bitmap images


Colour depth Metadata

Colour of each pixel is represented by an Literally "Data about data". Image


n-bit binary code. Number of colours metadata includes ...
(colour depth) is 2​n​.
★ Image size (width and height)
01 00 00 00 01 ★ Colour depth (bits per pixel)
Colour palette
★ Colour palette
00 10 10 10 00 ★ Resolution (pixels per inch)
00 : Black
★ Date created / edited
00 10 11 10 00
01 : White
10 : Red
00 10 10 10 00 11 : Green

01 00 00 00 01

1 bit : 2​1 ​ : 2 colours


4 bit : 2​4 ​ : 16 colours
24 bit : 2​24​ : 16777216 colors

24 bit colour uses 8 bits (0-255) to Without metadata, the device would not be
represent the levels of red, green and able to display the image.
blue in the image.
Decimal prefixes Binary prefixes

Measuring digital information in decimal Measuring digital information in binary

Quantity Unit Power Description Quantity Unit Power Description

bit b 0 or 1 bit b 0 or 1

nybble 4 bits nybble 4 bits

byte B 8 bits byte B 8 bits

kilobyte kB 10​3 ​ B 1000 B kibibyte kiB 2​10​ B 1024 B

megabyte MB 10​6 ​ B 1000 kB mebibyte MiB 2​20​ B 1024 kiB

gigabyte GB 10​9 ​ B 1000 MB gibibyte GiB 2​30​ B 1024 MiB

terabyte TB 10​12​ B 1000 GB tebibyte TiB 2​40​ B 1024 GiB

petabyte PB 10​15​ B 1000 TB pebibyte PiB 2​50​ B 1024 TiB

exabyte EB 10​18​ B 1000 PB exbiyte EiB 2​60​ B 1024 PiB

zetabyte ZB 10​21​ B 1000 EB zebibyte ZiB 2​70​ B 1024 EiB

yottabyte YB 10​24​ B 1000 ZB yobibyte YiB 2​80​ B 1024 ZiB


Pseudocode Structured English

A general non-specific algorithm language A general non-specific algorithm language


which uses words and symbols ... which uses words only ...

Flowcharts Flowcharts
Symbols Sequencing

Flowcharts use different shaped symbols Doing one thing after another ...
for different actions ...
Flowcharts Flowcharts
Selection Repeat ... Until

Doing one thing or another depending on Complete a sequence of tasks until a


the outcome of a decision. condition is met.

Flowcharts
While / For

While a condition is true, carry out a


sequence of tasks.
Compression Compression
Lossy
Reducing the size of a file whilst
maintaining as much content in the file Permanently remove detail from a file to
as necessary for the application reduce its size.

Compressed files ... Used for ...

★ Take up less storage space ★ Images


★ Require less bandwidth for ★ Sound
transmission over a network ★ Video
★ Transfer in shorter time over a
networks ... as removal of some detail doesn't
affect human perception of the media.

Compression Compression
Lossless Run Length Encoding (RLE)

Does not remove any detail from the file Replaces runs of similar data a single
so when it decompressed, it is the same data item and the number of times it
as the original. appears ...

Used for ... WWWBGTTTTJJWWWWBBDDDDDDUUJJJJ



★ Text files
3​W​1​B​1​G​4​T​2​J​4​W​2​B​6​D​2​U​4​J
★ Documents
★ Software / binary files
Results in only a slight reduction in
★ Some image types
file size.
★ Some sound types
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 Search algorithms
Linear search Binary search

Sequential search, starts at the Divide and conquer algorithm. Check


beginning moving one item at a time. middle item, discard half list and
Suited to an unordered list of items. continue. List has to be ordered.

Worst case - not in the list


Word case - not in list
Best case - first item in list
Best case - middle item

Sorting algorithms Sorting algorithms


Bubble sort Insertion sort

Compares adjacent items and swaps if Puts each item into the sorted portion of
necessary. Continues until no more swaps a list in the correct place.
or last one item left in unordered list.

Shows one pass


Sorting algorithms
Merge sort

Breaks an unordered list into parts and


builds it back up again in order.
Sound Sound
Analogue vs digital Sampling rate / interval

Sound waves are analogue (continually The frequency (samples per second, units
varying). Computers can only store sounds Hz) at which the amplitude of the
digitally (using binary). analogue wave is measured.

★ 8000Hz (8kHz) - Telephone


★ 16000Hz (16kHz) - VoIP
★ 44100Hz (44.1KHz) - CD quality
★ 48000Hz (48KHz) - Professional
★ 96000Hz (96KHz) - Bluray / DVD

Analogue wave More storage


Increase
sampled more space required
sampling
often and is to store more
frequence
better quality samples

Sampling interval is the gap between each


sample.

Sound Sound
Sampling resolution Bit rate

Number of bits (n) used to store the size Number of bits used to represent one
of each sample. Maximum amplitude of second of sampled sound.
analogue wave is broken down into 2​n
possible values. Given by ...

★ 4 bits - 16 values bit


=
sampling
x
sample
x channels
★ 16 bits - 65536 values rate frequence resolution
★ 24 bits - 16777216 values
Measured in kilobits per sec (kbps)
Quieter sounds
More storage ★ 32kbps - speech
Increase can be sampled
space required
sampling and sampled
to store more ★ 192kbps - medium quality streaming
resolution wave is closer ★ 320kbps - high quality streaming
samples
to original
Strings String slicing

Collections of characters. Extracting a portion of a string using


index values.

>>> message = 'Hello'


>>> message[0]
'H'
>>> message[4]
'o'
>>> message[5]
Strings are surrounded by quotation marks index out of range error
(which must match). >>> message[3:]
'lo'
>>> message[:4]​ # end is index+1
Each character in the string is located 'Hel'
using it's ​index​. >>> message[1:3]
'el'

0 1 2 3 4 Python REPL

H E L L O

Notice that the indices start at 0.

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 Well maintained code

Ensures programs function correctly Makes it easy for programmers to fix


errors and add features to the program.
★ Anticipate 'misuse'
★ Authenticate the user ★ Comments
★ Keep code well maintained ★ Indentation
★ Reduce errors through testing ★ Suitable variable and sub-program
names which reflect their purpose
★ Prefer local scope variables over
global scope

Analysis Design

★ Resources ★ Variables and data structures


★ Decomposition ★ User interface
★ Strategies ★ Testing plan
★ Success criteria ★ Robustness
★ Defensive design considerations ★ Real world utility
★ Real world utility considerations ★ Scope
Implementation Testing / evaluation

★ Techniques ★ Testing plan


★ Testing during development ★ Range of test data
★ Coding standards ★ Evidence of testing
★ Use of procedures and functions ★ Links to success criteria
★ Link to design / analysis ★ Corrective maintenance
★ Link back to original problem
Central Processing Unit (CPU) Clock speed

Processes data and instructions. Rate at which the Central Processing Unit
can perform operations, e.g. 4GHz - this
Central processing units often have means the CPU can perform 4 billion
multiple cores e.g. Dual core (2) or Quad operations per second.
core (4). Multicore processors are more
efficient because the cores can be given ★ Clock speed has implications for
jobs to perform simultaneously. power usage
★ Clock speed has implications for heat
generation

It is often more efficient to use a


multicore processor.

Cache memory Computer architecture

Volatile memory located within the CPU Von Neumann Architecture


chip and generally holds less data than
primary storage (RAM). This is the design of most CPU. Both the
program and the data is loaded into the
Manufacturing costs higher than RAM but same memory.
is faster. Typical capacities from 512kB
to 2MB per processing core. Harvard Architecture

Slower than registers but faster than RAM Programs and data are held in separate
and holds regularly used data. memories. Often used in embedded systems
(microcontrollers) where the program does
A bit like a handbag containing essential not change.
items.
Control unit Arithmetic and Logic Unit (ALU)

Coordinates the actions of the CPU. This is responsible for all the
arithmetic and logical operations in the
It sends out control signals to other CPU. E.g., Add, Subtract, divide,
parts of the CPU and controls data flow multiply, And, Or, Not, binary shifts.
inside the CPU.
The ALU contains the Accumulator.
The Control Unit decodes and executes
instructions following the Fetch - Decode
- eXecute (FDX) cycle.

Program counter (PC) Accumulator (ACC)

Program Counter This holds the MEMORY This stores the results of any
address (location) of the next calculations performed by the Arithmetic
instruction to be executed. and Logic Unit (ALU).
Memory Data Register (MDR) Registers
Memory Buffer Register (MBR)
Registers are very fast memory locations
Acts as a buffer, a storage place for on the CPU which help it to keep track of
data that is "on its way" to somewhere what it's currently doing. Register store
else. It holds data which has been data and the instructions.
requested by the CPU from the memory or
data which the CPU has requested is The main registers are the ...
written to memory.
★ Memory Data Register (MDR)
★ Memory Address Register (MAR)
★ Program Counter (PC)
★ Accumulator (ACC)

Memory Address Register (MAR) Fetch (Decode) Execute Cycle

The memory address register – This holds Each CPU core carried this process out
the address (location of) the place in billions​ of times per second!
memory that will be read during the FETCH
of the CPU.

★ FETCH : [PC] → [MAR]


[Memory] → [MDR]
[PC] → [PC] + 1
★ DECODE : Decode instruction
★ EXECUTE : Perform instruction
CPU Performance Graphics Processing Unit (GPU)

Depends on ... Special circuits designed to deal with


high demand graphics and video
★ Clock speed processing.
★ Number of processing cores
★ Size and type of cache Relieve load from the main CPU.

Can be used to perform extra processing


tasks if the CPU requires 'help'.
Packet transmission Packet switching

Data is sent through a network in Data is sent through a network in


packets. Each packet contains metadata packets. Each packet can take a different
which describes it. route but the data is recombined at it's
destination.

Rules are given in the Transmission


Control Protocol / Internet Protocol
(TCP/IP) suite of protocols.

Common network protocols TCP/IP network layers

TCP/IP is most important but there are Data passes through layers on it's way to
many, many others. and from clients and servers.

TCP/IP Transmission Control Protocol APPLICATION


4 Application Layer
IP Internet protocol
Data to files and vice versa
HTTP Hyper Text Transfer Protocol.
3 Transport Layer

HTTPS Secure HTTP Flow of packets, error checking


2 Network Layer
FTP File Transfer Protocol
Making connections, directing packets
POP3 Post Office Protocol V3
1 Link Layer

IMAP Internet Message Access Protocol Passing signals through a network

SMTP Simple Mail Transfer Protocol CABLES

UDP User Datagram Protocol


Anticipate misuse Exception handling

Input sanitisation Use to TRY.EXCEPT to handle unexpected


errors. The EXCEPT part will only run if
Remove unwanted characters from input the TRY part fails with a runtime error.
strings before processing
while True:
Input validation
try:
number = int(input('Number : '))
Check input against criteria
break
except:
★ Range check
print('That is not a number!')
★ Presence check
★ Format check Python
★ Type check
★ Lookup check
★ Length check
★ Check digit

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 Stakeholders

Ethical A person or group of people who have an


Issues considered right or wrong by interest or who are affected by a
society particular situation.

Legal ★ Company owner


Issues considered right or wrong in the ★ Employees
eyes of the law. ★ Shops
★ Customers
Cultural ★ Hardware / software supplier
The effect on groups of people with ★ Local community
particular beliefs, practices or
languages.

Environmental
The impact on the natural world.

Ethical considerations Ethical considerations


Privacy Censorship

Issues surrounding storage or access to When some organisation controls content


personal data through computer systems on or access to the Internet. Censorship
... is used to ...

★ Personal information held on website ★ Influence peoples views of the world


databases ★ Protect people (such as children)
★ Social media from pornography, gambling and other
★ Cloud computing inappropriate websites.
★ DNA profiling
★ National Identity cards
★ CCTV
★ Electronic tracking
Ethical considerations Ethical considerations
Surveillance Effect on wellbeing

Where an organisation monitors the ★ Constant new technology / upgrading


behaviour of a person or a group of ★ Peer pressure
people ★ Overuse of smartphones / tablets
★ 'Always on' culture - no breaks
★ Location (GPS / phone tracking) ★ Movement away from social interaction
★ Movement (CCTV)
★ Internet activity (ISP)

Ethical considerations Ethical considerations


Impact of social media Health problems

Keeping in touch ★ Excessive screentime


★ Eye strain
Easy to keep in touch with all your ★ Lack of exercise
friends and family. ★ Repetitive Strain Injury (RSI)
★ Posture / back problems
Cyberbullying ★ Obsessions / addiction
★ Poor diet resulting from excessive
Using social media to deliberately cause time spend gaming
emotional harm to someone else.

Trolling

Deliberately causing arguments online for


their own amusement, to cause offence or
to gain attention.
Cultural considerations Cultural considerations
Recreation Digital divide

★ Selfie culture The gap between people who have access to


★ Viral videos digital equipment and people who don’t.
★ Blogging
★ On demand music / video It might be because ...
★ Video calling
★ Lack of access to internet
★ Unable to afford it
★ Low IT literacy

Cultural considerations Cultural considerations


Changing face of business Changing face of education

eCommerce ★ Interactive whiteboards


★ Virtual learning environments
★ No need to maintain high street store ★ ebooks
which saves money ★ Computerised administration
★ Target a wider audience around the ★ Distance learning
world. ★ Independent learning
★ Customers can buy from any company ★ MOOCs / access to elite educational
around the world establishment from anywhere in the
World
Teleworking

★ Flexible working hours


★ Not tied to one location
★ Can work from home
Cultural considerations Environmental impact
Health
The impact of computers and computer
★ Online access to patient records systems on the environment.
★ 'Doctor Google'
★ Medical technology ★ Energy consumption
★ Remote surgery ★ Heat generation
★ DNA profiling ★ e-waste
★ Health insurance ★ Sustainability
★ Earths resources / mining
★ Recycling

Legislation Legislation
Data Protection Act 1998 Freedom of Information Act 2000

S​ – keep data ​SECURELY This is a law that gives you the right to
L​ – keep data ​LAWFULLY access information held by public
E​ – Only within the ​EU authorities E.g. government, health
E​ – Not ​EXCESSIVE ​data service, schools, police, courts
P​ – Only for ​PURPOSE ​intended

F​ – Keep data ​FAIRLY


L​ – Don’t keep data for ​LONGER
U​ – Keep data ​UP TO DATE
Legislation Legislation
Computer Misuse Act 1990 Copyright Designs & Patents Act
1998
Three levels of computer crime ...
This law protects people’s original work
★ Unauthorised access to computer from being used without their permission)
material
★ Unauthorised modification of computer ★ Intellectual property
material ★ Books
★ Unauthorised access to a computer ★ Films
system with the intent to commit ★ Music
crime. ★ Software
★ Ideas

Issues

★ Internet
★ Illegal file sharing
★ Copying for personal use

Creative Commons (CC) Ethical considerations


10 Commandments of Computer Ethics
A software license that allows the public
to have permission to share, remix, Thou shalt ...
develop and distribute work under certain
conditions. ★ not use a computer to harm other people
★ not interfere with other people's
computer work
Attribution ★ not snoop around in other people's
computer files
Attribution share-alike ★ not use a computer to steal
★ not use a computer to bear false witness
Attribution no-derivatives ★ not copy or use proprietary software for
which you have not paid (without
Attribution non-commercial permission)
★ not use other people's computer resources
Attribution non-commercial share-alike without authorization or proper
compensation
Attribution non-commercial no-derivatives ★ 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

Вам также может понравиться