Introduction to Computer and Python Programming
History of PYTHON
1.1 INTRODUCTION :
Nowadays computers have become an integral part of human lives. They are used in diverse sectors to execute a range of everyday tasks such as reservation of tickets, payments of electricity bills, virtual transfer of money, forecasting the weather, diagnosis of disease and so on. In short, each one of us -- directly or indirectly -- makes use of computers. So, before learning python programming language, this chapter explains the basics of computers and different types of programming languages for ease of beginners and then introduces Python in detail, covering installation and execution of Python and Python programs.
1.2 WHAT IS A COMPUTER :
The word computer is derived from 'compute' which means 'to calculate'. A computer is an electronic device which accepts data from a user, processes the data for calculations specified by the user and generates and output. A computer performs these operations with speed and accuracy using certain hardware and software. Hardware is visible physical element of a computer and software consist of a written set of instructions used to control the hardware.
The hardware of a computer of a computer system consists of three main components, viz. input/output (I/O) unit, central processing unit and memory unit.
1.2.1 Input/Output Unit
Users interact with a computer using various I/O units. Inputs can be given to a computer using input devices, such as a keyword. The input unit of a computer converts the data that is accepts from a user into a form that is understandable by it. As soon as the computer receives the inputs, it is processed and sent to its output device. Monitors, Printers, etc., are examples of output devices of a computer.
1.2.2 Central Processing Unit (CPU)
The CPU is one of the most important parts of a computer. It handles processing of data and consists of an arithmetic logic unit (ALU) and a control unit. The ALU performs all operations on the input data and the control unit directs the computer memory and input and output response to the instructions received from a program.
1.2.3 Memory Unit
The function of the memory unit is to store programs and data. The unit is a compilation of numerous storage cells and each cell can store one bit of information. These cells are processed in a group of fixed sizes of units called words and they never read or write as individual cells. A computer's memory system can be divided into the following three groups:
1. Internal Memory: It refers to the set of registers confined to the CPU. These registers hold temporary results when a computation is in progress.
2. Primary Memory: It is a storage area in which all the programs are executed. All programs and data must be stored in the primary memory for speedy execution.
3.Secondary Memory: It is known as external memory or storage memory. Programs and data are stored here for the long term. Hard disk, floppy disk, CDs, DVDs and magnetic tapes are different forms of secondary memory.
1.3 OVERVIEW OF PROGRAMMING LANGUAGES :
A computer program is a set of instructions, which performs a specific task when executed by a computer. Computer programs are commonly known as software. The instructions in a program tell a computer what to do and these instructions can be written in three types of programming languages described next.
1.3.1 Machine Language :
A computer is an electronic machine which can understand any instruction written in binary form, i.e. using only 0s and 1s. A program written in 0s and 1s is called machine language. While a computer easily understands this language, it is difficult for humans to write an instruction in terms of 0's and 1's.
Consider the following Example:
Example :
A series of numbers, such as 0011, 1000, 1010 is an instruction written in machine language. The instruction implies addition of a number stored at location 8 (1000) and another number stored at location 10 (1010) and storing the result at location 8 (1000). Here, the binary code 0011 stands for addition.
1.3.2 Assembly Language : From the above example, we know that it is difficult to write, read, communicate or change a program written in machine language for humans. Hence, the need to create another more convenient language arose. In assembly language, which was developed subsequently, machine operations are represented by mnemonic codes (such as ADD and MUL) and symbolic names that specify the memory address.
Consider the following Example:
Example :
MOV X, 10
MOV Y, 20
ADD X, Y
Here the mnemonic MOV indicates an operation to store the value of variable X a 10. The mnemonic ADD implies addition of the contents of variable X, Y and finally storing the result in variable X itself.
Since computers cannot understand the assembly language, a program called assembler is used to translate assembly language programs into equivalent machine language programs.
1.3.3 High-level Language :
High-level languages are much easier to write than low-level languages because programs written in these are similar to instructions written in the English language. Here 'high' does not imply that the language is complicated. It means that the language is more problem oriented. Generally, high-level language are platform independent. This means that one can write a program in high-level language and run it on different types of machines. Instructions written in high-level languages are called statements.
For example, A statement a calculate the square of a number can be written in a high-level language as
Square = number * number
There are many high-level languages and the selection of a language is based on the purpose it is expected to fulfill. A program written in a high-level language is called source code or source program. The process of executing programs written in high-level languages is given below.
- STEP 1: An interpreter or compiler is used to translate a program written in a high-level language into its equivalent machine code for execution.
- STEP 2: A linker is used to combine the object code and the code stored in libraries into machine language.
- STEP 3: Finally, the machine language code generated in Step 2 in executed.
The next section describes compiler, interpreter, linker and loader in detail.
GOOD
ReplyDeleteNice
ReplyDeleteThanks boss
Delete