Page 130 - Computer Science V2.0 Class 11
P. 130

GETTING STARTED WITH
                           5                                   PYTHON PROGRAMMING














                Chapter Outline


                5.1 Why Python?                                    5.2 Features of the Python Programming Language
                5.3 Shortcomings of Python                         5.4 Downloading and Installing Python
                5.5 Using the Python IDLE                          5.6 Exiting Python IDE







              Introduction

              We already know that a computer program is a finite sequence of instructions for a computer to perform a task. A
              program may be written in a low-level programming language such as machine language and assembly language or
              a high-level programming language such as BASIC, COBOL, C, C++, JAVA, Python. As programs written in high-level
              languages are easy to write and comprehend, most programs are written in high-level languages. A program written in
              a high-level programming language is called the source code. As a computer only understands binary language—the
              language of 0's and 1's, the source code must be transformed into a program in the machine language of the computer
              (expressed in 0's and 1's) with the help of an interpreter or a compiler. A program in the computer's machine language
              is called the object code or binary code.
              In the case of a compiled language such as Pascal, C, and C++, the compiler converts an entire program (source code)
              into machine language code (object code/ binary code) in one go. The compiler reports all the errors/ warnings to the
              programmer. The programmer rectifies the errors and re-compiles the program. If errors still remain, they also need
              to be corrected. When the program becomes error-free, the compiler generates the object code that can be executed
              to produce the results. On the other hand, in the case of an interpreted language such as Python, Perl, and PHP, the
              interpreter processes the source code in small chunks, often one statement at a time, generating the machine code
              and executing it. If an error is encountered in a statement, it has to be rectified before the interpreter can proceed
              further.




                       In which scenario, is a compiler preferable over an interpreter and vice versa?










               116   Touchpad Computer Science (Ver. 2.0)-XI
   125   126   127   128   129   130   131   132   133   134   135