FILE: PYTHON_2012_ONE

__ONE – HOW YOU WILL BE ASSESSED IN THIS MODULE__

There are five separate components to your final module mark:

EXAM (60%)

ASSIGNMENT (25%)

THREE MULTIPLE-CHOICE TESTS (Each 5%)

__TWO – HOW HAVE COMPUTERS CHANGED OUR LIVES?__

Computers have changed the way we live.

Using word processors to create many different types of document

Spreadsheets used for calculations in businesses

Computers controlling essential equipment in hospitals

Computer graphics used in films to create realistic sets

The World Wide Web providing access to a vast amount of information

Computers helping scientific research, like CERN and the Mars rovers

The eventual possibility, perhaps, of intelligent robots

Maybe there are some negative things as well:

Lonely people who say they have never actually met their ‘best friends’.

Spying on people by intercepting email.

People never reading real books

The eventual possibility, perhaps, of intelligent robots

__THREE – WHAT DO ALL THESE HAVE IN COMMON ?__

It is clear that there are a huge number of things that computers get up to. Can we analyse these and try and find something that they all have in common?

We can begin to understand what computers actually are doing by thinking about an experiment once carried out by an American astronomer, Frank Drake, who decided to use his (very early) radio telescope to transmit a radio signal rather than receive them from distant stars and galaxies.

He wanted to let any aliens out there know that human beings existed, and even to send them a picture of what we looked like. Of course he could only send a series of radio pulses, ‘high’ and ‘low’, or ‘long’ and ‘short’, or some other way which we could write down like this:

Frank’s signal to outer space:

**00101111111010000100010100101011011**

If you count you will find that there are 35 digits altogether. Frank Drake hoped that any aliens receiving his signal would realise that 35 is the product of two prime numbers, 5 and 7. If the signal is now written out again as seven rows of five digits a very simple picture of a ‘stick man’ appears:

**00101**

**11111**

**10100**

**00100**

**01010**

**01010**

**11011**

Of course Frank Drake used a much bigger number and so was able to code a moderately realistic picture. He made sure though that the total number of digits he sent was the product of two prime numbers to show the aliens that the code was for a particular rectangular shape. (Actually two possible rectangles as you can swap round rows for columns or vice versa.) Other numbers of digits would not make decoding so clear. if you don’t use prime numbers there are two many possibilities. For example 60 isn’t much good:

60 = 2 X 30

60 = 3 X 20

60 = 4 X 15

60 = 5 x 12

60 = 6 X 10

60 = 10 X 6

60 = 12 X 5

60 = 15 X 4

60 = 20 X 3

60 = 30 x 2

Here is an example you can try. What is this picture?

**00010000010000010100010100010001110001010010000010011001000001001100100000100110000000000011000010100001010000100001000111000111000000011100000**

Remember the stages you have to follow in decoding this signal:

*1. Count the number of digits*

*2. Find which two prime numbers have been multiplied together*

*3. Shade in a rectangle with this number of rows and columns*

__FOUR – COMPUTERS PROCESS DATA INTO INFORMATION__

In producing your picture you have been converting the raw data of the signal into useful (!) information, the picture that had been coded.

This is essentially what computers do. They process data into information. They are capable of processing vast amounts of data very quickly. This is why they have become so important in nearly every aspect of society.

One way of expressing this is to say that a computer accepts INPUT and produces OUTPUT.

__FIVE – ALGORITHMS__

In order to produce our picture we followed a set of clear, unambiguous rules:

*1. Count the number of digits*

*2. Find which two prime numbers have been multiplied together*

*3. Shade in a rectangle with this number of rows and columns*

A set of rules like this for solving a particular problem is called an algorithm. When a programmer writes a new program first they need to know what the relevant algorithms are.

(Note here that the accepted spelling for ‘program’ in a computing context is the American one. The British ‘programme’ should of course be used in the sense of ‘I dropped my theatre programme under the seat.’ or ‘I am following an intensive programme of study at university.)

[Practical exercise. Work through ‘integral value algorithm’ first on paper, then on white board]

What does this algorithm do?

*1. Begin with a decimal number, like 7.2*

*2. Subtract 1*

*3. If the answer is above zero repeat stage 1*

*4. Add one to the answer*

*5. Subtract the answer from the original number*

__SIX – BINARY ARITHMETIC__

We usually represent numbers as a decimal system. This means that we have ten separate digits we can use, 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 and that the value of any digit in a number depends upon its position relative to the other digits. For example the decimal system number 763 means 7 hundreds plus 6 tens plus 3 units. The place value of each digit is ten times the value of the digit to its right.

There is no reason why we should use ten as the basis for a system of numbers. In the binary system there are only two digits, 0 and 1. The value of each digit in this system is twice the value of the digit on its right. The binary number 1101 is one eight plus one four plus no twos plus one unit. We could write this as:

1101 = (1 X 8) = (1 X 4) + (0 X 2) + (1 x 1) = 13

Computers use binary arithmetic.

The 0 and 1 of binary arithmetic are called ‘bits’, a contraction of ‘binary digit’.

__SEVEN – WHY COMPUTERS USE BINARY ARITHMETIC__

Some of the very early computers did not use binary arithmetic. However they all do now. It is easy to represent a 0 or a 1 physically within an electronic system, for example two different levels of voltage. Anything which could exist in either two states could theoretically represent a binary number. Remember that computers depend basically upon ** two-state** physical devices. These are something that can only be one way or another, like a light switch which is ON or OFF (or, in the notorious joke by the philosopher John Searle, a beer can which can be EMPTY or FULL. American students can’t leave a half full beer can alone, we assume!)

The two state devices inside a computer are usually electrical voltages in the minute wires inside the computer. They can also be patterns of electrical charge, magnetic polarity on an old-fashioned floppy, the different reflecting layers on the surface of a CD etc. The important thing is that each device is in one state or another. These can be represented mathematically as the 1 or 0 of ** binary arithmetic**. A single two state device will correspond to a single binary digit, or

**.**

*bit*The number of separate items that can be held in a computer memory will depend upon how many bits there are available:

ONE BIT – This can be 0 or 1. There are TWO possibilities.

TWO BITS – Now there can be 00, 01, 10 or 11. There are FOUR possible things that can be represented by two bits. (This is 2 X 2.)

THREE BITS – This allows 000, 001, 010, 011, 100, 101, 110, 111. Now there are EIGHT possible separate combinations. (This is 2 X 2 X 2.)

FOUR BITS – There can be 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111. There are SIXTEEN different combinations. (This is 2 X 2 X 2 X 2.)

FIVE BITS – The total set of possible combinations is 00000, 00001, 00010, 00011, 00100, 00101, 00110, 00111, 01000, 01001, 01010, 01011, 01100, 01101, 01110, 01111, 10000, 10001, 10010, 10011, 10100, 10101, 10110, 10111, 11000, 11001, 11010, 11011, 11100, 11101, 11110, 11111. There are now THIRTY TWO, or (2 X 2 X 2 X 2 X 2.)

It can be seen that if there are N bits the number of separate combinations that exist will be 2 raised to the power N.

An important number of bits is eight. This is perhaps historical as much as anything. The earliest, useful computers worked with eight bits. The ** address bus** and the

**inside these computers consisted of eight separate tracks of wire, each capable of carrying a high or low voltage representing a 1 or a 0. The first cheap mass-produced microcomputers were all 8-bit machines. (16-bit microcomputers didn’t appear until the early 1980s. Eight bits is called a**

*data bus*

*byte.*__EIGHT – BINARY ARITHMETIC IS EASIER FOR A COMPUTER__

Binary arithmetic is actually easier to perform than decimal arithmetic.

When young children first learn arithmetic they have to memorise a large number of ‘number bonds’ like these:

2 + 4 = 6

1+ 3 = 4

8 + 5 = 13

Etc

(There are one hundred number bonds altogether)

All a computer needs is:

0 + 0 = 0

0 + 1 = 1

1 + 0 = 1

1 + 1 = 10

__NINE – WHAT ABOUT LETTERS?__

Obviously computers do more than work with numbers. Handling text is an essential role. This is achieved by letting numbers represent letters. For example capital A is 65, capital Z is 90, with corresponding values for the other letters in between. Lower case letters have a value 32 more than the capital letter. So lower case a is 97 and lower case z is 122.

This choice of number was quite arbitrary and established by agreement between various computer manufacturers and other organisations as American Standard Code for Information Interchange, or ASCII. Later it was expanded to create Unicode.

Here is an important secret message written in ASCII code. Can you translate it?

Hard version in binary:

**100 0011**

**100 0001**

**101 0100**

**101 0011**

**100 0101**

**100 0001**

**101 0100**

**100 0110**

**100 1001**

**101 0011**

**100 1000**

Easier version in decimal:

**67**

**65**

**84**

**83**

**69**

**65**

**84**

**70**

**73**

**83**

**72**

Similar, and arbitrary, conventions exist for representing negative numbers and fractions. The important thing to remember is that computers only ‘know about’ binary numbers. (eg represent physically a large (stupendous!) number of bits each as incredibly minute two state devices.)

__TEN – MACHINE CODE__

At its most basic level a computer only ‘understands’ instructions given to it in the form of binary numbers. These directly affect the way the hardware of the computer behaves. Some programmers have to work at this level, for example when a new processor is being developed.

__ELEVEN – ASSEMBLY LANGUAGES__

Binary numbers are difficult to remember and work with. an assembly language gets round this problem by having short words, more easy to remember, associated with each machine code instruction. Assembly programming is still difficult though. It is a low level language.

__TWELVE – HIGH LEVEL LANGUAGES__

High level languages are easier to program. Each instruction in a high level language will correspond to a large number of machine code instructions. All the ‘hard work’ has been done by the low level programmers who have produced the interpreter or compiler which converts the high level ‘source code’ into the low level ‘object code’ that the computer needs.

There have been a large number of different high level languages developed since the 1950s. At one time people hoped that there might be some ideal general purpose computer language that would be appropriate for every possible application, but this has never happened. Some high level languages have been:

Ada

Algol

Basic

C

Cobol

Currently visual programming, object-oriented programming and ‘Internet friendly’ languages are important. This course will use Python, which is regarded as a good first language for students and which Portsmouth University has adopted.

__THIRTEEN – SYSTEMS PROGRAMS__

A computer uses a lot of software which remains ‘invisible’ to the user. Such systems software is essential for the everyday ‘housekeeping’ of a computer, for example reading a keypress or reading from a memory device.

__FOURTEEN – UPLOADING PYTHON__

You do not have to purchase Python. It is a free download. You need to go to the official Python Website to download it to your own machine. Python is NOT on Moodle.

Do you have a similar assignment and would want someone to complete it for you? Click on the **ORDER NOW** option to get instant services at **essayloop.com**

Do you have a similar assignment and would want someone to complete it for you? Click on the ORDER NOW option to get instant services at essayloop.com. We assure you of a well written and plagiarism free papers delivered within your specified deadline.