computing theory guide
TRANSCRIPT
By Jack Jarman
10E
String (stings contain characters (text, numbers, symbols)#
Integer (a whole number without decimals you use integers for calculations)
Real e.g. floating point ( a number with decimals) , 6.786, 5.7.6
Boolean-yes/no or true/false
DATA TYPES
A variable is something that can change and can only hold one bit of data at one time, a variable must be a sign. For example a box is a good example of a variable as you can change that amount of 1 thing or what that thing is.
VARIABLE
Parentheses
Module
Function
Operator
Concatenate
comment
Key words
Module=orange
Function=purple
Integer=black
Variable=black
String=green
Comment=red
colours
A function is a block of organisation, reusable code that is used to perform a single, related action.
They are used for when you need to run the same piece of code multiple times.
The parentheses ( )
Function e.g. print
A python file generally contains definitions of variables, functions and classes.
module
+ - / * > <
If x>2
Print “x is higher than two!”
Else:print “x is less that three.”
Operations
It is the correct computer science term for joining two things together
concatenate
Commenting is one thing that separate an average programmer from a good programmer. If you type a hash (#) it will turn red and you type comments. It will not be noticed by python and will be ignored.
commenting
Bit, Byte and Binary
1 Bit = 1 bit
4 bits = 1 nibble
8 bits = 1 byte
1024 bytes = 1 kilobyte
1024 kilobytes = 1megabyte
1024 megabytes = 1 gigabyte
1024 gigabytes = 1 terabyte
Binary digit = BIT
What is a BIT
Computers cant work with our everyday denary.
Computers use ‘base -2’ number system which is ‘binary’ it : 0, 1
Computer numbers
Go into excel.
Type in an = sign
Then type in
Type in your number e.g. 0101001
Then close bracket
ENTER
Converting binary to denary
Go into excel.
Type in an = sign
Then type in
Type in your number e.g. 45
Close bracket
ENTER
Denary to binary
ADDING AND SUBTRACTING BINARY
1 and 1 = 10
1 and 0 = 1
0 and 0 = 0
How can you add these two binary numbers?
1001+0101
CPU-central processing unit
Hexadecimal digits represent four binary digits (bits), and the primary use of hexadecimal notation is a human-friendly representation of binary-coded values in computing and digital electronics.
One hexadecimal digit represents a nibble, which is half of a byte (8 bits)
Hex, or hexadecimal, is a number system of base 16. This number system is especially interesting because in our casually used decimal system we have only 10 digits to represent numbers.
As hex system has 16 digits, the extra needed 6 digits are represented by the first 6 letters of English alphabet. Hence, hex digits are: 0,1,2,3,4,5,6,7,8,9 and A, B, C, D, E, F.
HEXADECIMAL
So a single Hexadecimal digit can show 16 different values instead of the normal 10 like this:
Go into excel.
Type in an = sign
Type in a
Enter number e.g. 62
Close bracket
ENTER
CONVERTING DENARY TO HEXADECIMAL
American Standard Code for Information Interchange.
is a code for representing English characters as numbers, with each letter assigned a number from 0 to 127.
Most computers use ASCII codes to represent text, which makes it possible to transfer data from one computer to another.
ASCII
The standard ASCII character set uses just 7 bits for each character.
There are several larger character sets that use 8 bits, which gives them 128 additional characters.
The type of text you can use is limited to the standard Latin alphabet
This means that you cannot represent text in languages other than those based solely on the standard Latin alphabet. Mostly just English.
Limitations
A Digital Logic Gate is an electronic device that can process multiple bits at once and can make logical decisions based on the different combinations of the digital signals it receives.
DIGITAL LOGIC GATE
Two men approach the stile, can they get through to the next field?
A man and a dog approach the stile, can they both get through?
Two dogs approach the stile, can they get through to the other field?
CONSIDOR THIS STILE…
Most logic gates have two inputs and one output
The inputs it can read are either 1s (high) or 0s (low)
There are seven basic logic gates: AND, OR, XOR, NOT, NAND, NOR, and XNOR.
Rather than men and dogs, consider binary…
Input A = 1
Input B = 0
Output C = 0
Logic Gate
TRUTH TABLE
These are the basic gates: AND, OR AND NOT
AND gate
The AND gate is so named because, if 0 is called "false" and 1 is called "true," the gate acts in the same way as the logical "and" operator in Python.
The output is "true" when both inputs are "true." Otherwise, the output is "false."
AND gate
1 1 1
1 0 0
0 1 0
0 0 0
AND gate
If one is off the gate is not true and will not be activated
AND gate
OR gate
The OR gate gets its name from the fact that it behaves like the Python command "or."
The output is "true" if either or both of the inputs are "true." If both inputs are "false," then the output is "false.“
OR gate
X=A or B
OR gate
only 1 has to be activated for the gate to be true, whatever doorbell you press it will still sound the same bell
OR gate
NOT gate
The NOT gate, to differentiate it from other types of electronic inverter devices, has only one input. It reverses the logic state.
NOT gate
X=Not A
NOT gate
NOT gate
Individual logic gates can be connected together to form logic circuit diagrams, or larger logic gate functions.
Logic Circuit Diagrams
C
A
B
E
D
F
A B C D E F
0 0 0 0 1 1
0 0 1 0 0 0
0 1 0 0 1 1
1 1 1 1 0 1
1 0 1 0 0 0
1 0 0 0 1 1
MEMORY
Memory is the way the computer stores data
Data is stored in bits (binary digits)
Memory comes in the form of RAM or ROM
What is memory?
Main memory of the computer
Short-term computer memory
Stores data before it is saved to a file
Standard amount is 2GB
RAM is volatile
Important to save work as your going along so you do not loose anything
It does NOT automatically save
RAM – Random Access Memory
Desktop computers can normally hold more than one slot of RAM
Long term memory
Secondary storage choice
Examples:
• CDs
• DVDs
ROM – Read Only Memory
A form of long term memory (ROM)
Can be written to and read from (a bit like RAM)
Much slower than RAM
Non volatile
Hard disk drives
A computer’s processor searches for instructions that are stored in the RAM memory of the computer. If those instructions are not stored in the RAM memory, they will have to be transferred from the hard disk to the RAM memory - the well-known process of "loading" a program.
So, a greater amount of RAM memory means that more instructions fit into that memory and, therefore, bigger programs can be loaded at once.
How RAM affects a computer’s performance
Explain the difference between RAM and ROM
Research what DRAM is and explain it
Write a definition of volatile and non-volatile memory
Research and explain the term latency
Task – Update revision guide
ROM is memory that cannot be changed by a program or user. ROM retains its memory even after the computer is turned off. For example, ROM stores the instructions for the computer to start up when it is turned on again.
RAM
RAM is a fast temporary type of memory in which programs, applications and data are stored. Here are some examples of what's stored in RAM:
the operating system
applications
the graphical user interface (GUI)
If a computer loses power, all data stored in its RAM is lost.
Difference between RAM and ROM
Dynamic random-access memory (DRAM) is a type of random-access memory that stores each bit of data in a separate capacitor within an joined circuit.
DRAM
Volatile memory contrary to non-volatile memory, is computer memory that requires power to maintain the stored information; it retains its contents while powered, but when power is interrupted stored data is immediately lost.
VOLATILE
Non-volatile memory, non volatile memory, NVM or non-volatile storage is computer memory that can get back stored information even when not powered. Examples of non-volatile memory include read-only memory, flash memory, ferroelectric RAM (F-RAM), most types of magnetic computer storage devices (e.g. hard disks, floppy disks, and magnetic tape), optical discs, and early computer storage methods such as paper tape and punched cards.
NON-VOLATILE
Latency is the time it takes for a computers memory to respond after a request has been made
E.g. imagine you are in your room and your parents call you for dinner. The length of time it takes you to respond is Latency
RAM has less latency than a hard drive because it is Solid State (has no moving parts)
Latency
Sometimes a part of the hard drive can be used to store RAM. This is known as Virtual Memory
It causes more latency in the system but increases the size of a computers memory
By adding Virtual Memory you can increase the size of memory on a computer e.g. a computer with 1GB of actual memory + 1GB of virtual memory has 2GBs of memory it an use.
Virtual memory
The CPU cannot fetch the data it needs directly from the Hard Drive because the hard drive is at least 50 times slower. Fast memory is therefore required, the fastest type of memory is called Cache.
CACHE MEMORY
CPU Cache RAMDisk
StorageVirtual
Memory
RAM is faster than a hard drive but often has a bit rate of 128 or 256
Most CPUs now run at over 2GHz so RAM is still too slow for a processor
So the Cache’s ‘memory controllers’ have to predict what piece of data the CPU will need next. They then collect it from RAM and add it to their high speed memory.
This speeds up the systems performance
Why do we need Cache when we have RAM?
Explain the benefit of virtual memory
What is a computers Cache memory used for?
Update your revision Guides with these exam questions
Answer this question in approx. 500 words
Some suggestions to help:
phase-change memory (PCM)
magnetoresistive RAM (MRAM)
resistive RAM (RRAM)
How are changes in memory leading to innovative computer design?
Processor
The processing is carried out by a range of hardware such as a graphics card, a sound card, the operating system and the processor on the motherboard known as the CPU. The CPU is seen as the brain of the computer, translates all computer commands from binary to text we can understand. Also tells all of the computer components what to do.
What is a computers CPU?CPU = Central Processing unit
Often referred to as ‘the computer’s brain’
It’s purpose is to process data
It does this by performing functions such as searching or sorting data and calculating and decision making using the data.
Whenever you carry out a task on a computer the processor carries out all the data-processing associated with that task.
- e.g. design a spreadsheet, write an email, play a game or search the internet
What is a computers CPU?
Having two processors is like carrying out two jobs at once.
This is quicker and more efficient
Technology has continued to advance with the invention of quad-core and even hexa-core processors
Dual-Core Processors
BIOS stands for Basic Input/OutputSystem. This is the first place the processor goes to when a computer is switched on. This is accessed even before the Operating System is loaded. It is used to access initial instructions for booting a computer.
BIOS
The CPU undertakes the instructions it receives from programs in what is
called a cycleIf we go back to the making tea and toast example: if you worked faster you could produce the breakfast quicker, the addition of a faster kettle would help even more.
Not only does the CPU have multiple cores but it also has a speed. This
speed is measured in how many cycles it can perform per second.
The name given to one cycle per second is a hertz.
How does a CPU work?
The CPU undertakes the instructions it receives from programs in what is
called a cycleIf we go back to the making tea and toast example: if you worked faster you could produce the breakfast quicker, the addition of a faster kettle would help even more.
Not only does the CPU have multiple cores but it also has a speed. This
speed is measured in how many cycles it can perform per second.
The name given to one cycle per second is a hertz.
How does a CPU work?
A CPU that processes one million cycles per second is said to have a speed of one megahertz (MHz) and one billion cycles per second would be one gigahertz (GHz).
The faster the processor, the more processes it can complete but that results in the processor getting hotter and requiring more power.
How does a CPU work?
A computer accesses 3 different levels of cache:
Level 1- is always build into the CPU.
Level 2 - is built in separately on an external microchip stored on a motherboard. However, modern CPUs have the L2 cache built in. The faster the CPU, the larger the L2 cache needs to be. There is no fixed size for L2 cache but a standard amount at the moment is 512KB, it can be as high as 2MB.
Level 3 – is the name given to the extra cache which is built into motherboards
between the processor and the main memory.
The size of Cache can affect performance
Cache predicts what data will be needed next
The larger the cache the greater the amount of potentially needed data, therefore, the faster the computer
The size of Cache can affect performance
The same concept of cache is used on the internet.
When you visit a website the details of it are ‘cached’ on your computer.
The next time the web page is accessed, the computer will load what has been cached on the computer and then fetch any missing data from the internet.
This makes loading a webpage much faster.
Other uses for cache
Pseudocode
Pseudocode is a detailed yet readable description of what a computer program or algorithm must do, expressed in a formally-styled natural language rather than in a programming language.
Pseudocode is used when planning/designing code structures in a similar way to flow charts
What is Pseudocode?
Variables
Variables are assigned in Pseudocode using arrows to represent =
E.g.
customer_name “Steven”
Customer_age 45
Pseudocode
The first thing we do when designing a program is to decide on a name for the program.
Pseudocode
The first thing we do when designing a program is to decide on a name for the program.
Let’s say we want to write a program to calculate interest, a good name for the program would be CalculateInterest.
Note the use of CamelCase.
Pseudocode
So we start the program as:
PROGRAM CalculateInterest:
And in general it’s:
PROGRAM <ProgramName>:
Pseudocode
Our program will finish with the following:
END.
And in general it’s the same:
END.
Pseudocode
So the general structure of all programs is:
PROGRAM <ProgramName>:
<Do stuff>
END.
Pseudocode
When we write programs, we assume that the computer executes the program starting at the beginning and working its way to the end.
This is a basic assumption of all algorithm design.
We call this SEQUENCE.
Pseudocode
In Pseudo code it looks like this:
Statement1;
Statement2;
Statement3;
Statement4;
Statement5;
Statement6;
Statement7;
Statement8;
Pseudocode
For example, for making a cup of tea:
Organise everything together;
Plug in kettle;
Put teabag in cup;
Put water into kettle;
Wait for kettle to boil;
Add water to cup;
Remove teabag with spoon/fork;
Add milk and/or sugar;
Serve;
Pseudocode
Or as a program:
PROGRAM MakeACupOfTea:
Organise everything together;
Plug in kettle;
Put teabag in cup;
Put water into kettle;
Wait for kettle to boil;
Add water to cup;
Remove teabag with spoon/fork;
Add milk and/or sugar;
Serve;
END.
Pseudocode
What if we want to make a choice, for example, do we want to add sugar or not to the tea?
We call this SELECTION.
Pseudocode
So, we could state this as:
IF (sugar is required)
THEN add sugar;
ELSE don’t add sugar;
ENDIF;
Pseudocode
Or to check which number is biggest:
IF (A > B)
THEN Print A + “is bigger”;
ELSE Print B + “is bigger”;
ENDIF;
PseudocodeAdding a selection statement in the program:
PROGRAM MakeACupOfTea:
Organise everything together;
Plug in kettle;
Put teabag in cup;
Put water into kettle;
Wait for kettle to boil;
Add water to cup;
Remove teabag with spoon/fork;
Add milk;
IF (sugar is required)
THEN add sugar;
ELSE do nothing;
ENDIF;
Serve;
END.
Pseudocode
What if we need to tell the computer to keep doing something until some condition occurs?
Let’s say we wish to indicate that the you need to keep filling the kettle with water until it is full.
We need a loop, or ITERATION.
Loops are the same as iteration
Pseudocode
So, we could state this as:
WHILE (Kettle is not full)
DO keep filling kettle;
ENDWHILE;
Pseudocode
Or to print out the numbers 1 to 5:
A = 1;
WHILE(A > 5)
DO Print A;
A = A + 1;
ENDWHILE;
PseudocodePROGRAM MakeACupOfTea:
Organise everything together;
Plug in kettle;
Put teabag in cup;
WHILE (Kettle is not full)
DO keep filling kettle;
ENDWHILE;
Wait for kettle to boil;
Add water to cup;
Remove teabag with spoon/fork;
Add milk;
IF (sugar is required)
THEN add sugar;
ELSE do nothing;
ENDIF;
Serve;
END.
Flow charts
Re-cap – Theory
Computer programming is about creating a set of instructions to complete a specific task.
These are the fundamental building blocks of any program and any true programing language will contain all of these.
1. Sequence – the ORDER in which statements are executed.
2. Selection – the use of logic to select the statement to be executed.
3. Iteration – the use of repetition (to prevent typing the same code out many times a loop structure is used. For example While or For).
Flowchart
Turn A/C off(process)
False
Turn on A/C(process)
True
Temp > 25(decision)
End
Start
Temp(input)
The flow chart is made up of an input, decision and the alternative processes or actions.
You cannot have to yes’ or two no’s, (true, false)
with a diamond
start
Can you see in the
dark?
no
yes
stop
Is the lamp plugged in
yes
no
Plug in lamp
Is the bulb
Brocken
Fix bulb
Arrays
• In general, an array is a number of items arranged in some specified way - for example, in a list or in a three-dimensional table.
• An array is a data structure that contains a group of elements. Typically these elements are all of the same data type, such as an integer or string.
• Arrays are commonly used in computer programs to organize data so that a related set of values can be easily sorted or searched.
• This is like a variable but you can store more than one item.
• Arrays in python are called lists
Definition of Arrays
Arrays in Python
• The name given to Arrays in Python is Lists or Tuples
• In other programming languages Lists and Arrays are separate things
• Tuples are the same as Lists but they are Immutable
• Lists can be changed tuples can never be changed.
Creating Lists in Python
• A list is assigned in the same way as a variable but the square brackets are used to hold the values that need to be stored.
• Commas separate each item in the list
Name_of_list = [“item1”, “item2”, “item3”, “item4”]
• Brackets show where the list starts and finishes.
Printing a list using an index
Think of the index of a book – what is its purpose?
In programming the index of a list is the location of an item in a list which is denoted using a number
Items in a list are given an index number starting from 0
countries = [“France”, “Italy”, “Spain”, “Belgium”]
Adding to a listA list can be added to by using the append method of the list object
countries.append(“Great Britain”)
Note: square brackets are used to assign the list but parenthesis are used to call a method within the list object e.g. append
Removing from a list
An item in a list can be removed in the same way as append, however, the method ‘remove’ is used:
countries.remove(“France”)
France will now be removed when you print the list
Lists must be declared at the beginning of a programme
Empty list =
Operating Systems and Utility Programs
Explain the need for the following functions of an operating system:
• user interface - UI
• memory management
• peripheral management page 2 on PM
• multi-tasking
• security
Describe the purpose and use of common utility programs for:
• computer security
• system maintenance
USER INTERFACE
• a user interface (UI) brings structure to the interaction between a user and the computer
•Most leading computer companies have invested time and money in developing graphical user interfaces (GUI)
•Windows 8 and Apple’s OSx are examples of current operating systems which contain GUIs
• It's important to remember that the user interface is a program or set of programs that sits as a layer above the operating system itself
Memory Management
•Memory management is the functionality of an operating system which handles or manages primary memory• The memory management function
keeps track of the status of each memory location, either allocated or free• It checks how much memory is to be
allocated to processes. It decides which process will get memory at what time. • It tracks when memory is freed or
unallocated and updates the status.
Peripheral management
What are peripherals?
“able to be attached to and used with a computer, though not an integral part of it.”
Peripheral management
Device management controls peripheral devices by sending them commands in their own proprietary language. The software routine that knows how to deal with each device is called a "driver," and the OS requires drivers for the peripherals attached to the computer. When a new peripheral is added, that device's driver is installed into the operating system
Multi-tasking
Examples of operating systems
Security
If a computer program is run by unauthorized user then he/she may cause severe damage to computer or data stored in it. So a computer system must be protected against unauthorized access, malicious access to system memory, viruses, worms etc.
These are some of the areas a computers operating system can handle:
Unauthorised user – username/password to login and confirm your identity
Program Threats – Torjan horse, trap door, logic bomb, virus
System Threats - System threats refers to the misuse of system services and network connections to put user in trouble.
Trojan Horse - Such programs steal user login credentials and stores them to send to malicious user who can later on login to computer and can access system resources.
Trap Door Trap doors, also referred to as backdoors, are bits of code embedded in programs by the programmer(s) to quickly gain access at a later time, often during the testing or debugging phase. If an unscrupulous programmer purposely leaves this code in or simply forgets to remove it, a potential security hole is introduced. Hackers often plant a backdoor on previously compromised systems to gain later access.
Logic Bombs are small programs or sections of a program triggered by some event such as a certain date or time, a certain percentage of disk space filled, the removal of a file, and so on. For example, a programmer could establish a logic bomb to delete critical sections of code if she is terminated from the company
Virus - Virus as name suggest can replicate themselves on computer system. They are highly dangerous and can modify/delete user files, crash systems.
Utility Software
Computer security
Disk organisation
continued
System maintenance
Computer security
Research to find the answer – What do these three types of software do?
antivirus
firewall
Spyware protection
Disk Organisation
Formatting – Before a hard disk can be used, it needs to be prepared so that files and applications can be added to it.
Disk formatting is the initial part of the process in preparing a hard disk drive for its first use. As part of the disk formatting process ‘partitions’ are created. These are know to us as ‘drives’ and are assigned letters to represent them e.g. C: , D: , E:
File Transfer Windows Explorer is an example of a graphical utility software that enables you to view files, copy them and delete them.
Disk Organisation continued…
Defragmentation – You may notice after a while that your computer begins to run more slowly. There could be many reasons for this but one of the key reasons is that many of your files and folders become fragmented or scattered over time.
It is therefore a good idea to ‘defrag’ your hard disk.
All computers have a defragmenter utility pre-installed which will reorganise the hard drive by putting pieces of related data back together so that files are stored next to each other. This often frees up more space on the hard disk.
System maintenance
System information – The operating stores information about hardware such as make, clock speed, no. of processors etc.
System clean-up tools – A good disk clean-up tool will remove temporary files, old shortcuts and old installation files.
Automatic Updating – the software that you used, whether it be games or office applications, are constantly being redeveloped by the authors of the software. Most software is updated automatically using the operating system which checks the internet for any changes to software versions and automatically downloads and installs the update if it exists.
Antivirus or anti-virus software (often abbreviated as AV), sometimes known as anti-malware software, is computer software used to prevent, detect and remove malicious software. Antivirus software was originally developed to detect and remove computer viruses, hence the name.
A firewall is a program or device that acts as a barrier to keep destructive elements out of a network or specific computer. Firewalls are configured (in hardware, software, or both) with specific criteria to block or prevent unauthorized access to a network.
Anti-spyware (AS) software are programs that attempt to remove or block spyware – malicious programs that try and collect small pieces of information without the computer owner’s knowledge and may change settings, make your computer run slowly or affect other programs installed.
Antivirus, firewall, anti-spyware
values= [A, 2, 3, 4, 5, 6, 7, 8, 9, J, Q, K]
Suit= [“hearts”, “diamonds”, “spades”, “clubs”]
VALUES AND SUITS FOR C.A