Saturday, May 21, 2011

Python - Introduction

I have explained you about the history and deployment of Python in my previous post. Now I just started “Think Python” and here posting introduction to Python.

As other languages like C, C++, Java, Pearl and Visual Basic, Python is also a high level language. High level languages are written using easily understandable formal languages. They are easy to write and read. They can be run on different computers with no modifications, which increase its portability.

There are also low level languages which is the only language that a computer can directly execute. They are also called as machine languages or assembly languages. High level languages need to be converted into low level language before execution. This process time makes a disadvantage for high level language.

Two types of programs are used for this purpose.
  • Interpreter 
  • Compiler

Interpreter process a program a little at a time usually line by line. A compiler reads the program and translates it completely before the program starts running. Once a program is compiled, you can execute it repeatedly without further translation. Here the high level language is called as source code and translated code is called as object code.

Python programs are executed by interpreters. There are two modes to use the interpreter.
  • Interactive mode 
  • Script mode

In interactive mode, we can type Python programs and the interpreter prints the result:

>>> 2 + 4
6

Interactive mode

The >>> symbol is the prompt which is used by the interpreter to indicate that it is ready.
Alternatively, you can store code in a file and use the interpreter to execute the contents of the file, which is called a script. Python scripts have extension ‘.py’.
For testing small pieces of code interactive mode is convenient and for larger lines of codes script method is recommended.
More explanations regarding testing and debugging will be posted soon.
Thanks
AJAY

No comments:

Post a Comment

Comments with advertisement links will not be published. Thank you.