Computer Science Notes
Computer Science Notes
a task. ways:-
Consider the following as an example:- - Structured English
1 Take a spanner and loosen the wheel nuts. - Subset of English language that consists of
2 Position a jack in an appropriate place. commands to describe an algorithm.
3 Raise the car. - Pseudocode
4 Take off the wheel nuts and the wheel. - Makes use of keywords and identifiers
5 Lift replacement w heel into position . without following any particular syntax of
6 Replace wheel nuts and tighten by hand. a programming language.
7 Lower the car. - Flowchart
8 Fully tighten wheel nuts. - Makes of shapes that are linked together
These directions may seem pretty straightforward but not followed to represent the sequence in an algorithm.
correctly in sequence may result in the process becoming very
difficult maybe even impossible.
In computer Science all Algorithms make use of the following basic constructs when writing algorithms:-
- Assignment
- A value is given a name (identifier) or the value is changed.
- Sequence
- The steps the are performed on after the other.
- Selection
- Some steps are performed only under certain conditions. Otherwise different (or no steps are performed).
- Repetition
- Some steps are performed a number of times. A.K.A iteration or looping.
- Input, Processing and Output
- Programs involve data and that is why we need input and output statements.
Stages in Producing an Algorithm:-
• Make sure the problem is clearly defined.
• Break the problem into sub problems (each sub problem will require a separate algorithm)
• Problems can be divided into
• Set up
• input
• processing
• output results.
• Decide on how the data is to be stored, manipulated and then displayed.
• Decide on a method for constructing an algorithm, i.e. pseudo code or flowchart.
• Decided on suitable names (identifiers) for variable names.
• Create test data (normal, abnormal and boundary) and trace tables for finding errors.
• If any errors have been highlight then correct them and re-test the code until it works perfectly.
Local Variables:-
Variables that are used within a single module or subroutine (to be discussed later).
Global Variable:-
Variables that are used by all modules or subroutines.
Correlating Flowcharts and Pseudocodes:-
Database Structure:-
10000 1000
0 0 1000 100 10 1
The BINARY SYSTEM is based on the number 2. Thus, only the two „values‟ 0 and 1 can be used in this system to represent each
digit. Using the same method as denary, this gives the headings of 20, 21, 22, 23 and so on. The typical headings for a binary
number with eight digits would be
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
128 64 32 16 8 4 2 1
1 1 1 0 1 1 1 0
Simply add the values for the bits that are ON (1) together i.e.
128+64+32+8+4+1 = 23810 - Decimal to Binary:-
o Consider the denary number 116. The technique involves finding a weighted value (i.e 128,64,32,16,8,4,2,1) from
the binary number table that is either equal to 116 or nearest (yet smaller) to 116. Since there is no value equal to
116 the next suitable number would be 64 since 128 is larger than 116. This bit will be turned ON and 64 will be
subtracted from 116. 116 – 64 = 52. Repeat the steps till you have turned all the bits equating up to 116. Your
solution should look like.
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
0 1 1 1 0 1 0 0
NOTE: All even denary number will end with a “0” in binary and ODD will end in “1” in binary.
Bits, Bytes and Size of Computer Memories:-
A Bit is an abbreviated form of Binary Digit. There are 8 bits in one Byte. Bytes are the smallest unit memory in a computer.
Larger or smaller computer all contain multiples of bytes. For example:-
1 kilobyte = (1 KB) = 210 1 024 bytes
1 megabyte = (1 MB = 220 1 048 576 bytes
1 gigabyte = (1 GB) = 230 1 073 741 824 bytes
1 terabyte = (1 TB) =240 1 099 511 627 776 bytes
1 petabyte = (1 PB) = 250 1 125 899 906 842 624 bytes
(all numbers are 1024 × 1024 and so on)
To give some idea of the scale of these numbers, a typical data transfer rate using the internet is 32 megabits (i.e. 4 MB) per second
(so a 40 MB file would take 10 seconds to transfer).
Most hard disk systems in computers are 1 or 2 TB in size (so a 2 TB memory could store over half a million 4 MB photos, for
example).
Manufacturers of storage devices often use the denary system to measure storage size. For example, 1 kilobyte = 1000 byte 1
megabyte = 1000000 bytes 1 gigabyte = 1000000000 bytes 1 terabyte = 1000000000000 bytes and so on.
The Use if Binary Number Systems:-
Consider the working of a washing machine. As
can be seen in the diagram heater and wash
motor are ON while everything else is off for this
machine.
Binary Addition:-
Bit wise addition:-
Sum Carry
1+0 1 0
0+1 1 0
1+1 0 1
1+1+1 1 1
1 1 0 1 1 0 1 1 Byte 1
1 1 1 0 1 1 0 1 Byt3
1 1 0 0 1 0 0 0 Sum
*this bit can be ignored if the answer required is to remain within one BYTE.
Representing a Negative binary number:-
We use the following method to represent a negative number -76
Step 1:- convert the numeric part of the number into binary i.e. 76
128 64 32 16 8 4 2 1
0 1 0 0 1 1 0 0
Step2: Start moving from the right to left till you encounter the first “1”. Leave that bit and invert every bit that comes after
resulting in the following:-
128 64 32 16 8 4 2 1
1 0 1 1 0 1 0 0
Notice that the place value for the most significant bit(MSB) is -128, this will be case for all negative binary numbers. The next step
is to simply add the weighted values together to get…
-128+64+16+8+2 = -42
1.1.3Data Storage
Introductions:-
There are many formats in which data is stored such as images, sound, videos and even text. This section will explore the different
types of data as well as the different techniques used for file compression. Students will also here about primary memory and secondary memory
as well as the main technologies used in (magnetic, optical and solid state).
File Formats:-
We will look at MIDI, MP-3, MP-4, jpeg, text and number format.
MIDI:-
Musical Instrument Digital Interface is involved with the storage of music files. MIDI files are not music files and do not contain any
sound, they are different from MP3 and MP4 files. MIDI files basically contain a list of commands that instruct a device on how to create a
particular sound. MIDI operates on 16 different channels (0 to 15) and contains instructions that indicate what key is to played and how hard it
is to be played. It also contains additional bytes that include PITCH BYTE on what note to play and VELOCITY BYTE to tell how loud to play
a certain note. If this “.mid” file is played back using a musical instrument then it will play according to the original version. Due to its 16
channels the MIDI files can support up to 16 different instruments. Due to a complete lack of audio in MIDI files it is 10 times smaller than a
normal MP3 file.
MPEG-3 and MPEG-4
MPEG-3 (MP3) uses technology known as AUDIO COMPRESSION to convert music and other sounds into an MP3 file format.
Essentially, this compression technology will reduce the size of a normal music file by about 90 per cent. For example, an 80 megabyte music
CD can be reduced to 8 megabytes using MP3 technology. MP3 files are used in MP3 players, computers or mobile phones. Files can be
downloaded from the internet, or CDs can be converted to MP3 format using FILE COMPRESSION software. The converted version does not
match the full version of a CD but still is usable for most general purposes. With the help of PERCEPTUAL MUSIC SHAPING sounds that
the human ear cannot hear properly are removed hence reducing the size of the file without affecting the quality too much. The quality of MP3
files can be different since it depends on the BIT RATE – this is the number of bits per second used when creating the file. Bit rates are roughly
between 80 and 320 kilobits per second; usually 200 or higher gives a sound quality close to a normal CD. MPEG-4 (MP4) files allows the
storage and transfer of multimedia files rather than just sound i.e. music, videos, photos and animation over some medium such as the internet
without losing any real noticeable quality.
Joint Photographic Experts Group (jpeg) files:-
The resolution of the photographs is reduced from First to Last. The first two are somewhat
sharp but the last one is almost unrecognisable. This is the result of changing the number of
PIXELS per centimetre used to store the image (that is, reducing the PICTURE
RESOLUTION).
When a photographic file undergoes file compression, the size of the file is reduced. The trade-off for this reduced file size is reduced
quality of the image. One of the file formats used to reduce photographic file sizes is known as JPEG. As with MP3 format, once the image is
subjected to the jpeg compression algorithm, a new file is formed and the original file can no longer be constructed this is also known as Lossy
compression. Jpeg will reduce the RAW BITMAP, which can be of TIFF (.TIF) or BITMAP (.BMP) image, by a factor of between 5 and 15
depending on the quality of the original.
For Example:-
An Image is 2048 pixels wide and 1536 pixels high with a total of (2048 * 1536) = 3,145,728 in other words more than 3 megapixel image. Since there are
three main colours (RED, GREEN and BLUE) each colour takes up one byte therefore a 3 megapixel image will take up 9 megabytes (3 megapixels * 3). If the
same image stored in jpeg will take up .6 to 1.8 megabytes.
Text and Number Formats:-
Text and numbers can be stored in a number of formats. Text is usually stored in an ASCII format. It is important that the correct
format is chosen if some form of processing is to be done. If number files undergo any form of file compression, then it tends to be lossless.
Since it very important that none of the information/data is lost. If ASCII format is used to store text on a file, then the word COMPUTER
would be stored as either:
67 79 77 80 85 84 69 82 or %43 %4F %4D %50 %55 %54 %45 %52
(the first code is in denary and the second in hexadecimal)
Text files can also undergo file compression. These use complex algorithms that work on redundancy or repeated sections of words.
The following section shows, in very simple terms, how this could work: The phrase „THIS SECTION SHOWS YOU HOW THIS WOULD
WORK‟ consists of 35 memory units (ignoring spaces). Repeated words, such as „THIS‟ could be put into a data dictionary and be replaced by
„1‟. Repeated word sections, such as „HOW‟ and „OU‟ could be replaced by the numbers „2‟ and „3‟. Our phrase then becomes „1 SECTION
S2S Y3 2 1 W3LD WORK‟.
1.1.3Data Storage
Again, ignoring spaces, this compressed form now uses only 23 memory units. This is about a 33% saving in file size. Obviously if
whole pages are to be stored, then repeated words and word sections become even more numerous. This is clearly an example of lossless
compression since the original phrase can be reformed if necessary using the data dictionary and compressed file.
Lossless File Compression:-
With LOSSLESS FILE COMPRESSION, all the data bits from the original file are reconstructed when the file is again uncompressed. This is
particularly important for files where loss of any data would be disastrous – for example, a spreadsheet file.
Lossy file compression:-
LOSSY FILE COMPRESSION is very different to lossless file compression. With this technique, the file compression algorithm eliminates
unnecessary bits of data as seen in MP3 and jpeg formats. It is impossible to get the original file back once it is compressed. This is why it is
chosen for files where removing certain bits doesn‟t detract from the quality.
CS 0478 Topic 1.2
This method of data transmission works well over long distances. However, data is transmitted at a slower rate than parallel data
transmission. Since only one wire or channel is used, there is no problem of data arriving at its destination out of synchronization.
Parallel Data Transmission is when several bits of data (usually 1 byte) are sent down several wires or channels at the same time; one
wire or channel is used to transmit each bit.
This method of data transmission works very well over short distances (over longer distances, the bits can become ‘skewed’ – this means
they will no longer be synchronised). It is, however, a faster method of data transmission than serial. An example of its use is when
sending data to a printer from a computer using a ribbon connector:-
A common use for serial data transmission is Universal Serial Bus (USB) Parallel data transmission is used in the internal electronics of
the computer system. The pathways between the CPU and the memory all use this method of data transmission. Integrated circuits,
buses and other internal components all use parallel data transmission because of the need for high speed data transfer. 16-bit, 32-bit
and 64-bit buses, for example, allow much faster data transmission rates than could be achieved with single channel serial data transfer.
An internal clock is used to ensure the correct timing of data transfer; it is essentially synchronous in nature and the short distances
between components mean that none of the issues described earlier have any real impact on the accuracy of the data.
Asynchronous and Synchronous Data Transmission:-
This means that the receiver of the data knows when the data starts and when it ends. This prevents data becoming mixed up; without
these control bits, it would be impossible to separate groups of data as they arrived.
SYNCHRONOUS DATA TRANSMISSION is a continuous stream of data (unlike asynchronous data which is sent in discrete groups).
The data is accompanied by timing signals generated by an internal clock. This ensures that the sender and receiver are synchronised
with each other. The receiver counts how many bits (1s and 0s) were sent and then reassembles them into bytes of data. The timing must
be very accurate here since there are no control bits sent in this type of data transmission. However, it is a faster data transfer method
than asynchronous and is therefore used where this is an important issue (for example, in network communications).
Universal Serial Bus (USB):-
The UNIVERSAL SERIAL BUS (USB) is an asynchronous serial data transmission method. It has quickly become the standard
method for transferring data between a computer and a number of devices.
Essentially, the USB cable consists of:
- A four-wire shielded cable
- Two of the wires are used for power and the earth
- Two of the wires are used in the data transmission.
When a device is plugged into a computer using one of the USB ports the computer automatically detects that a device is present
(this is due to a small change in the voltage level on the data signal wires in the cable). The device is automatically recognised, and the
appropriate DEVICE DRIVER is loaded up so that computer and device can communicate effectively. If a new device is detected, the
computer will look for the device driver which matches the device; if this is not available, the user is prompted to download the
appropriate software.
Even though the USB system has become the industrial standard, there are still a number of benefits and drawbacks to using this
system.
Advantages Disadvantages
Devices plugged into the computer are The maximum cable length is presently about 5
automatically detected; device drivers are metres
automatically uploaded.
The connectors can only fit one way; this The present transmission rate is limited to less
prevents incorrect connections being made. than 500 megabits per second
This has become the industry standard; this Older Standards may not be compatible in the
means that considerable support is available to users. near future.
Several different data transmission rates are
supported
Newer USB standards are backward compatible
with older USB standards
Whilst you probably had little problem understanding this text, a computer would be unable to make any sense of it. This is why error
checking is such an important part of computer technology. This section considers a number of ways that can be used to check for errors
so that you don’t end up with text as shown in the example above!
A number of methods exist which can detect errors and, in some cases, actually correct the error. The methods covered in this section
are:
• Parity checking
• Automatic repeat request (ARQ)
• Checksum
• Echo checking
Parity Checking:-
PARITY CHECKING is one method used to check whether data has been changed or corrupted following transmission from one device
or medium to another device or medium.
• A byte of data, for example, is allocated a PARITY BIT.
• This is allocated before transmission takes place.
• Systems that use EVEN PARITY have an even number of 1bits
• Systems that use ODD PARITY have an odd number of 1-bits.
If this byte is using even parity, then the parity bit needs to be 0 since there is already an even number of 1-bits (in this case, 4). If odd
parity is being used, then the parity bit needs to be 1 to make the number of 1-bits odd.
Therefore, the byte just before transmission would be:-
Parity Blocks:-
Checksums:-
CHECKSUM is another way to check if data has been changed or corrupted following data transmission. Data is sent in blocks and an
additional value, the checksum, is also sent at the end of the block of data. To explain how this works, we will assume the checksum of a
block of data is 1 byte in length. This gives a maximum value of 28 – 1 (i.e. 255). The value 0000 0000 is ignored in this calculation.
Echo check:-
With ECHO CHECK, when data is sent to another device, this data is sent back again to the sender. The sender compares the two sets
of data to check if any errors occurred during the transmission process. As you will have no doubt worked out, this isn’t very reliable. If
the two sets of data are different, it isn’t known whether the error occurred when sending the data in the first place, or if the error
occurred when sending the data back for checking! However, if no errors occurred then it is another way to check that the data was
transmitted correctly.
MOD 11 Check Digit:-
A check digit is a number that is used to validate a series of numbers whose accuracy you want to insure. Frequently the last digit of a
number string such as identification number is a check digit. Lets say the identification number starts out at 6 digits. A calculation is
done using the six digits and a seventh digit is produced as a result of the calculation. This number is the check digit.
Weights x7 x6 x5 x4 x3 x2
Number * 0 18 30 20 9 4
Weights
0 + 18 + 30 + 20 + 9 + 4 = 81
If the remainder from the division is 0 or 1, then the subtraction will yield a two digit number of either 10 or 11. This won't work, so if
the check digit is 10, then X is frequently used as the check digit and if the check digit is 11 then 0 is used as the check digit.
Example of verifying the number 0365327 where 7 is the calculated MOD11 check digit:
0 3 6 5 3 2 7
x7 x6 x5 x4 x3 x2 x1
0 18 30 20 9 4 7
0 + 18 + 30 + 20 + 9 + 4 + 7 = 88
88/11 is 8 remainder 0
Since the remainder from this calculation is 0, the check digit 7 is valid.
Automatic Repeat Requests:-
Internet technologies:-
Internet Service Provider (ISP):-
Each user makes use of an INTERNET SERVICE PROVIDER (ISP); these are companies that provide the user with access to the
internet. A monthly fee is usually charged for this service. The ISP will set up a user account which will contain a username and a
password; most ISPs also give the user an email address. Before ISPs became common in the 1990s, internet access was usually limited to
users who were part of a university or a government agency.
Internet Protocol (IP) Address:-
Each device on the internet is given a unique address known as the INTERNET PROTOCOL (IP) ADDRESS. This is a 32-bit number
which is usually written in the form:
109.108.158.1
A home computer is given an IP address when it connects to the internet. This is assigned by the ISP and is unique for that particular
internet session. The only IP addresses that remain fairly unchanged are web servers. An IP address can be used instead of typing in the
full URL. For example “http://109.108.158.1” would take you straight to the device corresponding to this address.
IP addresses and MAC addresses:-
MEDIA ACCESS CONTROL (MAC) ADDRESS is a unique number that identifies a device connected to the internet. So what is the
difference between an IP address and a MAC address?
• The IP address gives the location of a device on the internet,
• whereas the MAC address identifies the device connected to the internet.
Consider the IP address as the address of the house you live in. The MAC address can be thought of as a way of uniquely identifying
each person living in that house. It is possible to move house (so your IP address will change) but the same people will be living in the
new house (so their MAC addresses will remain unchanged).
The web browser translates the web server name into an IP address which is part of the URL. The HTML code is returned and is shown
as a correctly formatted page on the computer screen. It is also possible that cookies may be sent from the web browser to the web server
when the code is executed.
What is a Cookie?
An HTTP cookie is a small piece of data sent from a website and stored on the user's computer by the user's web browser while
the user is browsing.
Therefore
1 0 1 1 1 1 1 0 0 0 0 1(2) = B E 1(16)
- Hexadecimal to Decimal:-
o Consider the Hexadecimal number ABE(16)
162 161 160
256 16 1
A B E
10×256=2560 11×16=176 14×1=14
2560 + 176 + 14 = 2,750 (10)
Therefore
ABE(16) = 2,750 (10)
- Decimal to Hexadecimal:-
o The process involves the following steps
Convert the decimal number to binary
The convert the binary number to hexadecimal as mentioned before.
The Use of Hexadecimal Numbers:-
1. Memory Dumps:-
Since it is much easier to work with B 5 A 4 1 A F C rather than 1 0 1 1 | 1 0 0 1 | 1 0 1 0 | 0 1 0 0 | 0 0 0 1 | 1 0 1 0 | 1 1 1 1 | 1 1 0 0 hexadecimal is often used when
developing new software or when trying to trace errors in programs. The contents of part of the computer memory can hold the key to help solve many problems. Hexadecimal is
often used when developing new software or when trying to trace errors in programs. The contents of part of the computer memory can hold the key to help solve many problems.
2. Hypertext Markup Language (HTML):-
(HTML) is used when writing and developing web pages. HTML isn’t a programming language but is simply a mark-up language. A mark-up language is used in the processing,
definition and presentation of text (for e.g, specifying the colour of the text). HTML uses hexadecimal number to represent the different colors by varying the intensity of the three
primary colors (RED, GREEN and BLUE).
Hexadecimal Number RED GREEN BLUE Color
FF0000 FF 00 00 Red
00FF00 00 FF 00 BLUE
0000FF 00 00 FF GREEN
FF0099 FF 00 99 PINK
3. Media Access Control (MAC):-
A MEDIA ACCESS CONTROL (MAC) ADDRESS refers to a number which uniquely identifies a device on the internet. The MAC address refers to the network interface card
(NIC) which is part of the device. A MAC address is usually made up of 48 bits which are shown as six groups of hexadecimal digits (although 64-bit addresses are also known).
Consider the MAC Address:- 60:F1:89:5A:BB:D4
Vendor# Serial#
NN NN NN DD DD DD
60 F1 89 5A BB D4
The first three digits (NN:NN:NN) represent the vendor id and the final three digits (DD:DD:DD) represent the device ID.
4. Web addresses:-
Each character used on a keyboard has what is known as an ASCII CODE (AMERICAN STANDARD CODE FOR INFORMATION INTERCHANGE). These codes can be
represented using hexadecimal values or decimal values. A good example of the use of ASCII codes is the representation of a web address (or URL, which stands for uniform
resource locator)
Computer memory can be referred to directly using machine code or assembly code. This can have many advantages to program developers or when carrying out troubleshooting.
Control unit
The control unit is a component of a computer's central processing unit (CPU) that directs operation of the processor. It tells the computer's memory,
arithmetic/logic unit and input and output devices how to respond to a program's instructions.
It directs the operation of the other units by providing timing and control signals. All computer resources are managed by the CU (Control Unit).It directs the
flow of data between the Central Processing Unit (CPU) and the other devices. The Control Unit makes decisions and sends the appropriate signal down its
lines to other parts of the computer. It controls the timing of operations in the computer and controls the instructions sent to the processor and the peripheral
devices.
The fetch-execute cycle
An instruction cycle (sometimes called fetch-and-execute cycle, fetch-decode-execute cycle, or FDX) is the basic operation cycle of a computer. It is the process by
which a computer retrieves a program instruction from its memory, determines what actions the instruction requires, and carries out those actions. This cycle is
repeated continuously by the central processing unit (CPU), from boot-up to when the computer is shut down.
- Fetch Phase:-
1. The PC copies the address of the next instruction to be fetched into the Memory Address Register.
2. The Memory Address Register places the address on the Address Bus (one directional channel from processor to main memory for
transferring addresses of memory locations)
3. The MAR triggers are read signal that causes main memory to place instruction being asked on the Data Bus (two way channel b/w CPU
and RAM that is used for transferring programs and data).
4. The instruction on the data bus is sent to the MDR/MBR.
5. This instruction is then copied to the Current Instruction Register.
- Decode Phase:-
o The CPU will now examine the instruction in the CIR and “decodes” it. This means that a special part of CPU known as the Decode Unit
will make the rest of the CPU ready to carry out the instruction by sending out microinstructions. Every CPU has its own set of legitimate
instructions known as the Instruction Set. All software eventually ends up being instructions from this instruction set.
- Execute Phase:-
o After decoding the instruction a special part of the CPU known as the Execute Unit will carry out execution. After execution the PC will
point towards the next instruction.
1.3.3 Input Devices
Scanners:-
Scanners are either 2 Dimensional or 3 Dimensional but their purpose is the same; to convert an image which is physical form into digital form to be stored on
a computer.
- 2 Dimensional Scanners:-
The following steps take place for during the working of a 2-Dimensional scanner.
o The cover is raised, and the document is placed on the glass panel and the cover is closed.
o A very bright light illuminates the documents. The scan head rolls under the document thereby returning the image to a lens with the help
of a mirror.
o The image falls on a Charged Couple Device (CCD) which is composed of integrated circuits etched on silicon. The CCD is made of
thousands of light sensitive elements that create a charge when light falls on them. This way the an electronic version of the image is
formed.
Computers equipped with OCR (optical character recognition) allow the scanned image to be converted to a document therefore
allowing editing.
2D Scanning is used in Airports
For scanning passports.
For facial recognition.
- 3 Dimensional Scanners:-
This type of scanner is used when we want to create a scan of 3 Dimensional Figure by capturing the x, y and z coordinates of the real object. This
technology is heavily used in Computer Aided Design (CAD) allowing the electronic version of an image to be send to a 3 Dimensional Printer to
create a working model of a scanned image. There are numerous technologies used in 3D scanners – lasers, magnetic resonance, white light, and so
on.
Barcode readers/scanners:-
A barcode is a series of dark and light parallel lines of varying thickness. The numbers 0 to 9 are each represented by a unique series of lines. Various barcode
methods for representing these digits exist. The UPC ((Universal Product Code) version A) adopts different codes for digits for both left and right. The actual
left-hand and right-hand sides of the barcode are separated using guard bars and each digit is represented by bars of 1 to 4 blocks thick.
Guard Bars Table Representation
Representation of 543052
QR Codes are also a type of Barcodes but unlike the latter, they are made up of filled in dark squares on a light background. Such as .A normal barcode
can hold up to 300 digits whereas a QR code can hold over 7000 digits. Because of modern smart phones, which allow internet access on the move, QR codes
can be scanned anywhere. This allows advertising of products on trains, buses, shopping malls and many other places with the help of built in technology and
QR reading App.
- Advantages Include:-
o There is no need for the user to write down or key in a website address; scanning the QR code does this automatically
o QR codes can store website addresses/URLs that appear in magazines, trains, buses or even on business cards, giving a very effective method
of advertising
Digital cameras:-
Digital cameras have replaced the traditional cameras that used film to capture photos. The film required developing before any results could be seen, making a
photography a very lengthy and expensive process. Digital cameras can now be easily connect to any computer with the help of USB cable or wireless
connections. The photograph is captured when light passes through the lens onto a light sensitive cell and processed by a microprocessor. This cell is made up
of tiny elements known as pixels. The number of pixels determines the size of the file used to store the photograph.
Keyboards:-
The most common input device it is used for inputting text, numbers, punctuation marks, symbols and instructions using a number of software applications. By
pressing down a key completes an electrical circuit. This circuit then transmits a binary signal (commonly using ASCII) to the computer to represent the key
1.3.3 Input Devices
pressed. Keyboards are a relatively slow method of data entry and are also prone to errors. However, frequent use of these devices can lead to injuries, such as
REPETITIVE STRAIN INJURY (RSI) in the hands and wrists. Modern ergonomic keyboards can help solve this problem.
Mouse:-
A pointing device that functions by detecting motion relative to its 2 dimensional surface.
- Laser Mouse:-
o A laser mouse uses a light source, typically a LED, and a light detector to detect movement relative to a surface. It is an alternative to the
ball mouse which uses moving parts to perform the same function.
o The light source is focused towards the surface below. The reflected light falls back to the camera integrated in Optical Mouse Sensor.
o The camera takes images of the surface with a frequency in the range of 1500 to 6000 images per second to calculate the position of mouse.
o These images are processed by Digital Signal Processor (DSP) and resultant co-ordinates are sent to the PC. The driver of the mouse
installed in the computer receives the co-ordinates and makes the cursor move on the screen accordingly.
- Tracker Ball:-
o Trackerballs are seen more often in an industrial environment – such as a control room. Because they don’t need to move, the trackerball
doesn’t need any desk space or special surface. The operator is also less likely to suffer from injuries such as RSI. A ball on the top of the
trackerball is moved to control a cursor on the screen.
Microphones:-
These devices are used for inputting sound to a computer. They can either be built-in or be connected as external devices. When a microphone picks up sound,
a diaphragm vibrates producing an electric signal. This signal goes to a sound card and is converted into digital values and stored in the computer. If the
microphone is being used in a VOICE RECOGNITION system, the user’s voice is compared to that stored in memory for identification. In SPEECH
RECOGNITION system the user’s voice is used to identify different words for further processing.
Touchscreens:-
Touchscreens are now a very common form of input device. They allow simple touch to launch an application or to carry out many of the functions of pointing
devices such as a mouse. One of the main uses of touchscreen technology is in mobile phones. There can be the following types:-
Capacitive:- Made up of many layers of glass that act as capacitor. Touching the top layers will result in an electrical change as a result of which the on board processor will
determine the coordinates of the place touched. It is medium cost, with sunlight legibility and allows for multi touch. The screen is also very durable. However, the user must use
bare fingers only to make use of such touch screens.
Infra Red(Heat and Optical):- In Heat based the coordinates of placed touched on screen is determined by some warm object coming in contact (i.e. fingers.). Whereas in
Optical, sensor detect disturbance in infra red light grid hence causing the coordinates to be identified. Both have multi touch and good screen legibility. The optical type even
allows for screen to be touched using gloves. However it is an expensive technology.
Resistive:- The top layer of screen is polyester and the bottom layer is glass. When touch the top and bottom layer come in contact as result of which a complete circuit is formed
and the coordinates are identified. Cheap technology and it is possible to use with gloves. Does not allow multi touch, poor legibility in sun light.
Sensors:-
Sensors are devices that read physical quantities from their surrounding in analogue form. To be cable of process this data is converted into digital data using an
ANALOGUE TO DIGITAL CONVERTER (ADC).
Some Types of Sensors
Sensor Measures Where Used
Heat Temperature Living room for central heating system
Humidity Water vapour in the air Swimming pool, greenhouse
Infra-red Infra-red radiation e.g. body heat Security alarm systems
Light Light levels External security lights
PH Acid/alkali levels e.g. pH of soil Environmental experiments, river pollution
Pressure Pressure Burglar alarm systems, automatic doors
Smoke Smoke in the atmosphere Offices
Sound Levels of sound Security alarm systems
Tilt Angle of tilt Windows in security alarm system
Touch Detects if one object bumps into another Computer controlled robots
Sample Questions Using Sensors:-
Working:- Possible Sensors:-
The Sensors take input from surrounding. The data is in Analogue form and Student should be able to mention
is converted into digital form using ADC. This digital data is sent to the the appropriate type of sensors based
microprocessors as a result of which the system undergoes the appropriate on the scenario. Knowledge of the
changes. purpose of all sensors is a must.
Primary memory is computer memory that is accessed directly by the CPU. This includes
several types of memory, such as the processor cache and system ROM. However, in most cases,
primary memory refers to system RAM.RAM, or random access memory, consists of one or
more memory modules that temporarily store data while a computer is running. RAM is volatile
memory, meaning it is erased when the power is turned off. Therefore, each time you start up
your computer, the operating system must be loaded from secondary memory (such as a hard
drive) into the primary memory, or RAM.
Similarly, whenever you launch an application on your computer, it is loaded into RAM. The operating
system and applications are loaded into primary memory, since RAM can be accessed much faster than storage devices. In fact, the data can be transferred
between CPU and RAM more than a hundred times faster than between the CPU and the hard drive. By loading data into RAM, programs can run
significantly faster and are much more responsive than if than constantly accessed data from secondary memory. DVD RAM is a recent addition to the optical
media group. Unlike other CD and DVD formats, DVD RAMs have several discrete concentric tracks rather than a single spiral track. This gives them the
advantage that writing and reading can occur at the same time. This makes it possible to watch an already recorded television program at the same time as
different program is being recorded.DVD RAMs can written to many times.DVD RAMs have a long life estimated to be 30 years and re-write operation can be
carried out over 100,000 times which is 100 times more than RW formats.
Secondary memory refers to storage devices, such as hard drives and solid state drives. Unlike primary memory; secondary memory is not accessed directly by
the CPU. Instead, data accessed from secondary memory is first loaded into RAM and is then sent to the processor. The RAM plays an important intermediate
role, since it provides much faster data access speeds than secondary memory. By loading software programs and files into primary memory, computers can
process data much more quickly. While secondary memory is much slower than primary memory, it typically offers far greater storage capacity. For example, a
computer may have a one terabyte hard drive, but only 16 gigabytes of RAM. Secondary memory is non-volatile, meaning it retains its data with or without
electrical power. RAM, on the other hand, is erased when a computer is shut down or restarted. Therefore, secondary memory is used to store "permanent
data," such as the operating system, applications, and user files.
Hard disk:- A hard disk is really a set of stacked "disks," each of which, like phonograph records, has
data recorded electromagnetically in concentric circles or "tracks" on the disk. A "head” records
(writes) or reads the information on the tracks. Two heads, one on each side of a disk, read or write
the data as the disk spins. Each read or write operation requires that data be located, which is an
operation called a "seek." (Data already in a disk cache, however, will be located more quickly.) A hard
disk/drive unit comes with a set rotation speed varying from 4500 to 7200 rpm. Disk access time is
measured in milliseconds. The physical location can be identified with cylinder, track, and sector
locations.
Solid state devices (SSDs):- Solid-state drives actually aren't hard drives in the traditional sense of the term, as
there are no moving parts involved. A traditional hard disk drive (HDD) consists of a spinning disk with a read/write head on a mechanical arm. An SSD, on
the other hand, has an array of semiconductor memory organized as a disk drive, using integrated circuits (ICs) rather than magnetic or optical storage media.
Off-line storage is any storage that is not currently online, live or connected to the computer. The data stored in offline storage remains permanently in the
storage device even if it’s disconnected or unplugged from the computer after the data has been stored. Offline storage is generally portable in nature and can be
used on different computer systems. Common examples of offline storage include floppy disks, compact disks and USB sticks.
Solid state memory:- Solid state systems control the movements of electrons within the microchip. The 1s and 0s are stored in millions of miniature transistors
within the microchip. If a transistor conducts a current this is equivalent to a 1 otherwise 0.they consequently have no moving parts, consume much less power
and are extremely robust.
Memory sticks/pen drives:- It uses solid state technology to store several GBytes of data. It is usually connected to a computer through the USB port and power
to operate them is drawn from the host computer. They are small and very portable. Memory sticks and pen drives are used for transporting files between
computers or as a backup store. They are used a security device, a dongle, to prevent software piracy
Flash memory cards:- These are a form of electrically erasable programmable read only memory (EEPROM) and are another example of solid state memory.
They are used to store photos on digital cameras. Mobile phones use them as memory cards. They are also used in MP3 players to store music files. They are very
compact and robust.
Compact Disks (CDs):- The data is stored as a series of pits (equivalent to binary 1) and lands (equivalent to binary 0) in metallic optical layer. The pits are
formed by a laser beam etching the surface at the manufacturing stage. Only a single track exits which spirals out from the centre of the disk.
The pits and lands are read by a low-powered laser beam which follows the data stream and reads from the centre outwards in a spiral. The light reflects
differently off a pit than it does off a land and this interpreted a s1s and 0s.
DVDs:- DVDs can hold up to ten times the amount of data that a CD can store.DVD writers use a shorter wavelength of laser light than CD writers do, so the
pit on the disk surface is a lot smaller and more can be stored in the same space.
CDs and DVDs are cheaper and robust than hard disks but data transfer rates and access times for both are slower than hard disks.
Blu-ray:- These have largest capacity of all optical disks up to 100 GB or more. It uses a shorter wavelength for its laser beam, using light that is close to the
blue/violet spectra rather than the red light used by other optical devices. They are mostly used for storing films (movies)
1.3.4 Output Devices
Inkjet Printers:-
Description and Main Components The Working
The print head portion is made up of nozzles that spray tiny droplets of ink Data is sent to the printer driver. The driver makes sure that data is the
onto paper to form the characters. The ink comes from cartridges one for appropriate format for printing. It also makes sure that the printer is ready
colour and one for black. This ink can be formed from a thermal bubble and available. The data is sent to the printer buffer where it is stored whilst
(heat causes ink to vaporise forming a tiny bubble resulting in the ejection of ink) or waiting to be printed. After a sheet is fed to the printer the head starts moving
piezoelectric (in which a crystal is given a tiny charge resulting in vibration as result of from side to side printing the document. At each complete movement of the
which the ink is ejected). A motor moves a belt that moves the print head across head across the sheet of paper the sheet is moved a little so that printing can
the sheet of paper. The paper feed automatically feeds printer with paper be done on the next line. When buffer is empty more data is sent for printing
when required. with the help of an interrupt until there is no more.
Application:- INKJET PRINTERS are best for one-off photos or where only a few pages of good quality, colour printing are needed; the small ink cartridges or
small paper trays would not be an issue with such applications.
Laser Printers:-
Description and Main Components The Working
Unlike inkjet printer, laser printers print document using powders instead of This type of printer produces very high quality hard copy. It consists of drum
liquid ink. With the help of static electricity and heating these printers are that is electrically charged. A laser is used to change the charge on the drum
capable of printing documents at a much faster rate. Apart from the fact that for each dot of the output to be produced. Electrically charged toner is then
laser printers are capable of printing many more documents than inkjets, they attracted to the oppositely charged dots. The paper presses against the toner
are also capable of printing documents in one go. coated drum and is output with the pattern of dots required which is then
heated in order to permanently fuse the text/imagery. The page cannot be
printed until the whole document has been stored in a large buffer.
Application:- LASER PRINTERS produce high quality printouts and are very fast when making multiple copies of a document; any application that needs high-
volume printing (in colour or monochrome) would choose the laser printer (for example, producing a large number of high quality flyers or posters for
advertising) they have two advantages: they have large toner cartridges and large paper trays (often holding more than a ream of paper).
3D Printers:-
Description and Main Components The Working
3D PRINTERS are primarily used in COMPUTER-AIDED DESIGN (CAD) A design is created using a CAD software. The design is then exported in a
applications. They can produce solid objects which actually work. The solid format that is understandable by the printer. The 3D printer is set up to start
object is built up layer by layer (additive manufacturing) as opposed to removal printing. The object is then printed in thin layers. This can take up to several
of material to make an object (subtractive manufacturing e.g. carving of wood) hours depending on the size of the object. After printing the excess material is
using materials such as powdered resin, powdered metal, paper or ceramic removed and the object is left to settle for a few hours.
powder. Direct 3D printing uses inkjet technology in which the print head can
move in all directions. Binder 3D printing involves a powder type material
being sprayed first in the required shape followed by a glue that form a solid
layer.
Application:-This kind of printing is considered as the next industrial revolution. Possible applications include; prosthetic limbs, reconstructive surgery of body
parts, aerospace manufacturing using lightweight materials, fashion industry and even making objects that are no longer in production.
2D and 3D Cutters:- Both 2D and 3D cutters work in the same way being able to cut through various materials such as glass, crystal, metal and even wood
therefore being able to create intricate designs. However 2D cutters operate on “x” and “y” planes only whereas 3D cutters are capable of cutting through “x”,
“y” and “z” planes.
Actuators:- An actuator is an output device but it does not always provide output directly to the user. It can change some physical value in response to a signal
from an automated system or control system. Actuators naturally pair up with sensors, which can provide feedback to the control program about the effects of
its actuators.
Speakers:- Data is stored in digital form in computers. Therefore, to be able to create sound with the help of speakers, the sound has to pass through a DAC at
certain rate known as a “sampling rate”. To make these vibrations, speakers have a set of magnets. One of them is called the permanent magnet. It doesn’t move
or change polarity and is made of a magnetic metal like iron. The other magnet is an electromagnet. It is a coil of metal wire like copper or aluminum. When an
electric current is sent through the electromagnet, it is either attracted to or repelled away from the permanent magnet. The polarity of the coil can be reversed
depending on the current. This back and forth movement causes the diaphragm or cone to vibrate, because it is connected to the magnetic coil. This is the
sound that you hear.
LCD and LED:- LCD Short for liquid crystal display is a type of display used in digital watches and many portable computers. LCD displays utilize two sheets of
polarizing material with a liquid crystal solution between them. An electric current passed through the liquid causes the crystals to align so that light cannot pass
through them. Each crystal, therefore, is like a shutter, either allowing light to pass through or blocking the light. The LCD screen is more energy efficient and
can be disposed of more safely than a CRT. Its low electrical power consumption enables it to be used in battery-powered electronic equipment. LED (Short for
light emitting diode) is a flat-screen device in which an array of light-emitting diodes can be selectively activated by processor to display numerical
and alphabetical information ,used esp in pocket calculators ,digital timepieces, measuring instruments , and in some microcomputers.
DLP Projectors or digital light processing, uses tiny mirrors to reflect light toward the screen (an "on" pixel) or away (an "off" pixel). Most models use a color
wheel, literally a spinning wheel with color filters to create sequential color. Some high-end models use three DLP chips; one each for red, green, and blue.
DLP projectors range in price from a few hundred dollars to tens of thousands, and more. Most projectors in movie theaters use DLP.
LCD Projectors, which stands for liquid crystal display, is very similar to the technology found in most TVs. LCD projectors use three liquid crystal panels, each
tasked with creating an image using just one of the primary colors (red, green, and blue). All three are projected on the screen at once, so you see a full color
image.
LED vs. DLP projectors
DLP is significantly more expensive than LCD, but requires less ongoing maintenance.
LCD projectors are portable and lightweight.
DLP quality is superior to LCD (although LCD is sufficient for most usage).
Film, photography, highly detailed graphics and images, etc., will all appear crisper and brighter with DLP technology as compared to LCD.
CS 0478 Topic 1.3.7
People use many different languages to communicate with each other. In order for two people to understand each other they
need to speak the same language or another person, an interpreter, is needed to translate from one language to the other language.
Programmers use many different programming languages to communicate with computers. Computers only ‘understand’ their own
machine code. A program needs to be translated into machine code before it can be ‘understood’ by a computer.
Programming languages:-
What is a program?
Programs are our way of telling a computer what to do, how to do it and when to do it. This enables a single computer to
perform many different types of tasks. A computer can be used to stream videos, write reports, provide weather forecasts and many,
many other jobs. A COMPUTER PROGRAM is a list of instructions that enable a computer to perform a specific task. Computer
programs can be written in high-level languages or low-level languages, depending on the task to be performed and the computer to be
used. Most programmers write programs in high-level languages.
High-level languages:-
High-level languages enable a programmer to focus on the problem to be solved and require no knowledge of the hardware and
instruction set of the computer that will use the program. Many high-level programming languages are portable and can be used on
different types of computer. High-level languages are designed with programmers in mind; programming statements are easier to
understand than those written in a low-level language.
This means that programs written in a high-level language are easier to:
• Read and understand as the language used is closer to human language
• Write in a shorter time
• Debug at the development stage
• Maintain once in use.
The following snippet of program to add two numbers together is a single program statement written in a typical high-level language. It
shows how easy it is to understand what is happening in a high-level language program:
• Sum := FirstNumber + SecondNumber
There are many different high-level programming languages in use today including
• C++
• Delphi
• Java
• Pascal
• Python
• Visual Basic
• and many more.
Once a programmer has learnt the techniques of programming in any high-level language, these can be transferred to working in other
high-level languages.
Low-level languages:-
Low-level languages relate to the specific architecture and hardware of a particular type of computer. Low-level languages can refer to
machine code, the binary instructions that a computer understands, or an assembly language that needs to be translated into machine
code.
Assembly language:-
Few programmers write programs in an assembly language. Those programmers who do, do so for the following reasons:
• to make use of special hardware
• to make use of special machine-dependent instructions
• to write code that doesn’t take up much space in primary memory
• to write code that performs a task very quickly.
The above code written in assembly language will add two numbers together.
In order to understand this program the programmer needs to know that
• LDA
– means load the value of the variable into the accumulator
• ADD
– means add the value of another variable to the value stored in the accumulator
• STO
– means replace the value of the variable by the value stored in the accumulator.
The above words are referred to as mnemonics.
The above code is a portion of a program to add two numbers together is written in typical machine code, shown in both hexadecimal
and binary. As you can see, this is not easy to understand in binary! Machine code is usually shown in hexadecimal
Translators:-
Computer programs can exist in several forms. Programs are written by humans in a form that people who are trained as computer
programmers can understand. In order to be used by a computer, programs need to be translated into the binary instructions, or
machine code, that the computer understands. Humans find it very difficult to read binary (hexadecimal is easier to understand) and
computers can only perform operations written in binary. A program must be translated into binary before a computer can use it; this is
done by a utility program called a translator. There are several types of translator program in use; each one performs a different task
Compilers:-
A COMPILER is a computer program that translates a program written in a high-level language (HLL) into machine code so that it can
be directly used by a computer to perform a required task. Once a program is compiled the machine code can be used again and again to
perform the same task without recompilation
The high-level program statement…
Interpreters:-
An INTERPRETER is a computer program that reads a statement from a program written in a high-level language, performs the action
specified and then does the same with the next statement and so on.
Assemblers:-
An ASSEMBLER is a computer program that translates a program written in an assembly language into machine code so that it can be
directly used by a computer to perform a required task. Once a program is assembled the machine code can be used again and again to
perform the same task without re-assembly.
The assembly language program statements…
An executable file of machine code No executable file of machine code An executable file of machine code
is produced is produced. is produced.
One high-level language statement One high-level language program One low-level language statement is
can be translated into several statement may require several usually translated into one machine
machine code instructions machine code instructions to be code instruction
executed.
Compiled programs are used Interpreted programs cannot be used Assembled programs can be used
without the compiler. without the interpreter. without the assembler
A compiled program is usually An interpreter is often used when a An assembled program is usually
distributed for general use. program is being developed. distributed for general use.
Python IDE
User Interface:- Users make use of a system known as (User Interface) that allows them to interact with the computer. There are two types:-
- Graphical User Interface
- Command Line Interface
Graphical User Interface (GUI) Command Line Interface (CLI)
Description:- Description:-
It is built around a collection of visual objects which include:- They do not provide visual elements to their users. Instead the user interacts
- Windows:- regions of the screen to display info. with the system using commands which are to be typed in on a black screen.
- Icons:- small pictures that represent folders and sw. The user will have to learn a wide range of commands to be able to effectively
- Menus:- a list of options that the user can select. use the system.
- Pointer:- is an arrow that be moved around to select various visual
objects.
Advantages:- Advantages:-
Are very easy to use due to their visual nature. CLI is very light weight and does not require powerful processors due to their
lack of visual elements.
Disadvantages:- Disadvantages:-
Due to their graphics, powerful computers are needed to run them. GUI is Commands are very difficult to use. Only meant for expert users.
very resource hungry.
Single-tasking OS:- This type of OS allows the running of only program at a time. (not used any more)
Multiprogramming OS:- This type of OS holds more than one program in memory. There are two types of Multiprogramming OS 1) Multitasking OS 2)
Multiuser OS.
- Multitasking OS:- The OS swaps programs in and out of the memory when needed.
- Multiuser OS:- This type of OS allows multiple users on different networks to be connected using some network to share processing time of a central
computer. The OS switches back and forth between different users giving each user a “time slice” of processing time.
Batch Operating System:- The Users of a Batch OS do not interact with the OS directly. Instead these users, prepare their inputs separately and hand them
over to a computer operator. The computer operator then proceeds to process these inputs once when a certain number of inputs have been arranged or if a
certain amount of time has passed. For example, processing utility bills at the end of the month after meter reading staff has provider their inputs.
Real Time Operating System:- Such data processing systems are used in control environments. As a result of which the time taken for processing an input is
very small. The response time (the time taken from receiving input to updating the system) is very small. For e.g. EFU controller of a car, heart rate monitoring
system.
Transaction Processing system:- The input is noted by the computer, but deals with them after a short delay. Meanwhile, it handles other inputs and data
management. The delay is short but considerably longer than real time processing. For example, booking flight tickets, ATM.
Interrupts:- An Interrupt is a signal sent from a device attached to a computer of from a program within the computer that causes the OS and CPU to stop
what it is doing and attend to the device/software sending the signal. Today all computers (large or personal) are interrupt driven. Opposed to the Polling
technique in which the CPU wastes valuable clock cycles prompting hardware/software if it needs services of the CPU. Interrupts are used all over the
computer, such as with devices such as printer or keyboard (in which each key stroke generates an interrupt).
Interrupt Service Routine:- Interrupt are handled using the Interrupt Service Routine. The Operating systems has smaller software component that is referred
to as the Interrupt Handler. Consider the following ISR for when a mouse moves:-
1. Mouse moves.
2. A hardware chip on the motherboard called the Interrupt Controller detects the mouse signal.
3. The Interrupt controller issues an interrupt signal and sends it the CPU.
4. Upon receiving the signal the CPU copies its registers’ content on a stack located on the main memory so that it can return to what it was doing
after dealing with the interrupt.
5. The CPU then starts executing the Interrupt Service Routine by moving the cursor image to the new location on screen and also responding to
any mouse clicks (if any).
6. After the ISR is completed, the CPU reloads the register values from the stack to carry on what it was doing before the interrupt.
It is the responsibility of the Interrupt handler prioritizes interrupts and arranges them in a queue while multiple interrupts are waiting to be dealt with.
Interrupts can Hardware Interrupts (such as an I/O operation) and Software Interrupts (such as a software requesting services of an OS). A Timer Interrupt is
generated by an internal clock indicating that the processor must attend to time critical activities.
CS 0478 Topic 1.4
Firewalls can be customised using the following methods based on their threat levels:-
You can create or disable firewall filter rules based on conditions such as:
• IP Addresses
Blocking off certain IP addresses, which you think are harmful.
• Domain names:-
You can only allow certain specific domain names to access your systems/servers. Or even specify the types of
domains such as .edu or .org
• Protocols:-
A firewall can decide which of the systems can allow or have access to common protocols like TCP/IP, FTP
or UDP.
• Ports:-
Blocking or disabling ports of servers that are connected to the internet will help maintain the kind of data
flow you want to see it used for & also close down possible entry points for hackers or malignant software
• Keywords:-
Firewalls also can sift through the data flow for a match of the keywords or phrases to block out offensive or
unwanted data from flowing in
If users know that their actions are being monitored then they are less likely to deliberately damage or steal data. Logs can also be used to
help trace any accidental damage to data. A log cannot stop a person from damaging or stealing data but it can help identify the culprits
Backups:-
There is also a very big risk of interception. If the secret key is sent across a network and this key is intercepted, then a
hacker is able to decrypt the data as they have possession of the secret key.
Despite these issues, symmetric encryption is reliable and allows for fast decryption. It is still a very popular method of
encryption and is used by many large organisations to manage the transmission of online communication. Symmetric key
encryption is simple and fast but its main drawback is that the two parties must somehow exchange the key in a secure way.
This problem is overcome by using public and private key encryption to transfer the symmetric key before then using
the symmetric system to transfer data. In order to transfer the symmetric key securely, public and private key encryption is often
used.
• Public key (asymmetric) encryption using two keys - one public key and one private key:-
Public key encryption is used to transfer data but is actually often used to transfer the key needed to allow symmetric
encryption to take place. This is because symmetric encryption is a much faster method than using public and private keys.
Public keys are keys that are unique to a user profile on an operating system and are available to all systems trying to
communicate with the user’s computer.
If a message has to be sent to the user’s computer, then the public key that matches their profile is used to encrypt the
data. Private keys are also unique to a user profile when running an operating system but are not available to any other
computers and are not transferred from system to system. This means, with private keys there is no risk of interception. If an
operating system receives a public key, it needs to use its own private key to decrypt the data. If the public key it has received
was actually intended for another system, the private key will not be able to decode the data. If the public key it receives is its
own public key, then the private key will decode the data.
When system A wishes to send a secure message to system B, it will use system B’s public key to encrypt the data.
System B then uses its own private key to decrypt the data.
Using public and private keys to exchange symmetric keys securely is a very common occurrence. Symmetric keys are
then used to transfer the actual data.
What is Ethics?
Ethics is a set of moral principles that govern the behavior of a group or individual. Therefore, computer ethics is set of moral
principles that regulate the use of computers.
Some common issues of computer ethics include
• Intellectual property rights (such as copyrighted electronic content)
• Privacy concerns,
• How computers affect society.
For example, while it is easy to duplicate copyrighted electronic (or digital) content, computer ethics would suggest that it is wrong to do
so without the author's approval. And while it may be possible to access someone's personal information on a computer system,
computer ethics would advise that such an action is unethical.
Ethical behavior is not necessarily related to the law.
• For example, just because something is not against the law doesn't mean it is okay to do it.
Philosophers today usually divide ethical theories into three general subject areas:
• Met ethics:-
• Met ethics investigates where our ethical principles come from, and what they mean. Are they merely social
inventions?
• Normative ethics:-
• Normative ethics takes on a more practical task, which is to arrive at moral standards that regulate right and wrong
conduct.
• Applied ethics:-
• Finally, applied ethics involves examining specific controversial issues, such as abortion, infanticide, animal rights,
environmental concerns, etc.
(you do not have to memorise this…this is just for information)
Computer ethics is concerned with the procedures, values and practices that govern the process of consuming computing technology and
its respective disciplines without harming or violating the moral values and beliefs of any personal, organization or entity.
“Computer ethics can be understood as that branch of applied ethics which studies and analyzes social and ethical impact of
information technology.”
Violation of copyright law may results in fines, imprisonment or Plagiarism may result in academic dismissal or loss of job.
both.
Freeware, Shareware and Free Software (Open Source):-
Hacking:-
Types of Hackers:-
White Hat Hackers Grey Hat Hackers Black Hat Hackers
People who Specialise hacking to Exploit the systems security to gain People who break into networks and
check the system faults. the attention of the owners. harm to the network and property.
They are the good guys. Also known
as ethical hackers.
Hacking Vs Cracking:-
Note the difference between CRACKING and HACKING. Hacking is breaking into a computer system to steal personal data without
the owner’s consent or knowledge (e.g. to steal a password file). Cracking is where someone edits a program source code (i.e. looks for a
‘back door’ in the software so that the code can be exploited or changed for a specific purpose). This is usually done for a malicious
purpose (e.g. legitimate software could be altered by a cracker to perform a different task e.g. send a user to a specific website).
Essentially, hacking isn’t necessarily harmful whilst cracking is ALWAYS totally illegal and is potentially very damaging.
• A computer virus is a program that attaches itself to an application or "host file" and then spreads by making copies of it. Some
type of human action (e.g. opening an attachment) is always required for a virus to take effect. Once a virus gets onto your
computer it might modify, delete, or steal your files, make your system crash, or take over your machine.
• A computer worm is like a virus, but it infects other computers all by itself, without human action and without a host file. It
usually infects other computers by sending emails to all the names in your email address book.
• A Trojan horse is a program that tricks you into running it by appearing useful or harmless. However, once it is run, it damages
your computer, usually by providing "back door" access to the computer. This allows hackers to control or use your computer,
destroy or steal files, install viruses or spyware, or run arbitrary programs.
• A root kit is a program that allows an intruder to gain access to your system without your knowledge by hiding what it is doing
on the system. The intruder can then install difficult-to-detect back doors into your system to seize control.
Phishing:-
Wardriving:-
Spyware:-
Arrays are data structures that store the same type of data usually in random order.
Temp ßMyList[6]
MyList[6]ßMyList[3]
MyList[3]ßTemp
Swapping two values in an array
FOR count 1 to 7
PRINT MyList[count]
NEXT
END FOR //index position changes from count 1 to 7
//and prints all elements in array. 25,34,98…
Step Wise Refinement refers to the process of splitting a problem into smaller sub problems. These sub problems are then divided into even
smaller sub problems until each problem represents just one element of the final program.
Sub problems can be referred to as “Sub Routines”. The Resulting diagram is known as Structure Chart.
Subroutine:-
A subroutine is a self-contained section of the program code that performs a specific task as part of the main program. Sub routines can be
either procedures (Null Function) or functions (Fruitful Function).
Library Routines:-
A LIBRARY ROUTINE is a set of programming instructions for a given task that is already available for use. It is pre-tested and usually
performs a task that is frequently required.
Test Data:-
To determine whether a solution is working as it should it needs to be tested. Both whole system and subsystems as well.
In order to be tested fully it needs to be worked through several times with different test data i.e SET OF TEST DATA. Test data needs to
be of the following types:-
• Normal Test Data:-
• Will result on normal execution of the program to produce results. The produced result should then be compared with the
“expected” results. If both achieved results and expected results are same then the codes is working as it should.
• For example the normal test data for percentages of exam results achieved can be
• 50,60,80,70,100
• the expected value when finding average of these percentages should be 72.
• Erroneous Or Abnormal Test Data:-
• Should be rejected by the program and appropriate expected steps should be executed (for example printing an error message).
• for percentages of marks the following data should result on errors:-
• -11 and eleven.
• Extreme Data:-
• The upper and lower limits of acceptable value (should be accepted)
• 0 and 100 are extreme values for exam percentages scenario.
• Boundary Data:-
• The data that lies beyond the acceptable range. (should be rejected)
• 101 or -1
Validation • Range Check
Is data • Only numbers in specified are accepted
Sensible? • Percentages should be between 0 and 100
• Length Check
• The number of characters should be a certain number.
• Passwords need to be at least 8 characters long.
• Type Check
• Data has to be a certain type.
• Number of brothers and sisters need to be whole numbers only. (integers values)
• Character Check
• String of characters should not include invalid characters
• A name should not have # or %
• Format Check
• The character should be of a pre defined pattern
• User ID should have 2 letters and then 4 numbers. AB1234
• Presence Check
• A field or data cannot be left empty.
• Email address must be entered.
• Check Digits
• Final digit in code is calculated with existing data. If the recalculation results in a different value then an error is identified.
• ISBN or Vehicle Identification numbers
• Line 7:-
• Our rogue value is the counter becoming more than 30. But here we can see that
the counter is not incrementing rather decrementing in each iteration (step). The
statement should be counter=counter+1
We have studied the use of basic constructs such as assignment, sequence, selection, iteration, input and output.
We will now study the Python Syntax for these basic constructs.
Some interesting details about Python:-
- Every statement must be on a separate line.
- Indentation is significant. This is known as the 'off-side rule’.
- Keywords are written in lower case.
- Python is case sensitive the identifier Number1 is seen as different from number1 or NUMBER1 .
- Programs are interpreted (refer to previous concepts about compilers, interpreters and assemblers).
- Python files have a .py extension
- Python files can be edited and created using IDLE (a Python editor).
A python file
where code is
written →
EXAMPLES:-
DECLARE number : INTEGER
//number is declared as an integer
DECLARE name : STRING
//name is declared as string
DECLARE n1,n2,n3 : INTEGER
//three numbers n1,n2,n3 as integer
Variable Assignment:-
SYNTAX:-
<Identifier> <value>
EXAMPLES:-
number 0
name “Hassan”
Declaration of Constants
SYNTAX:-
CONSTANT <Identifier> <value>
EXAMPLE:-
CONSTANT Pi = 3.142
Arithmatic Operators:- DECLARE num1,num2,sum,prod,divwhole,rem : INTEGER
DECLARE div2 : REAL
input “enter the second number”, num2 // can be written in same line too
// say num1 is 5 and num2 is 2
sum = num1 + num2
//sum will be assigned 7
Operator precedence:- prod = num1*num2
1. Brackets. //prod will be assigned 10
2. Exponents. divwhole = num1 DIV num2
3. Multiplications. //divwhole will be assigned 2
4. Division. rem = num1 MOD num2
5. Addition. //rem will be assigned 1
6. Subtraction. div2 = num1 / num2
//div will 2.5
print “The Sum is=” , sum, “ The Product is =”, prod, “ The Whole Division is=”, divwhole,
“ The Remainder is=”, rem
// this is as example of printing “prompts” in line with variable values.
//will print in the following manner
//The Sum is=7 The Product is=10 The Whole Division is=2 The Remainder is=1
print “The division with decimal places is…”
print div2
//the variable type of div is real therefore it will have complete division as
Data Types in Python:-
Further Data Types →
Boolean Expressions:-
These expressions evaluate
to either TRUE or FALSE.
CASE of Grade
“A” : PRINT “you have achieved an A grade”
“F”, “U” : PRINT “you have failed”
“B”…“E”: PRINT “Passed”
OTHERWISE
PRINT “Invalid Grade”
END CASE
END FOR
FOR count 1 TO 10
PRINT count * 2
NEXT
END FOR
//the counter controlled loop will run 10 times.
WHILE num<>0
input num
total = total + num
END WHILE
More Python Built In Functions
Features of an IDE (Integrated Development - Prettyprinting:-
Environment):- - Colour coded
key words
- Context Sensitive Prompts:- - Indentation
- displays hints or a choice of keywords - Comments
appropriate for current insertion point of
code.