What is Python…?
Python is an simple, interpreted, object-oriented, high-level , open source programming language with dynamic semantics.
Characteristics of Python
- Simple and Easy to Learn
- Free and Open Source
- Interpreted Language
- Cross-platform language
- Object-Oriented language
- Extensive Libraries
- Databases Connectivity
Simple and Easy to Learn-There are excellent, straightforward tools to work with python code, especially the interactive interpreter; you don’t need to learn a build system, IDE, special text editor, or anything else to start using python. All you need only a command prompt and the interactive editor.
Free & Open source – Freely distributed and Open source Maintained by the Python community
Interpreted– Python is an interpreted language i.e. interpreter executes the code line by line at a time. When you use an interpreted language like Python, there is no separate compilation and execution steps. You just run the program from the source code. This makes debugging easy and thus suitable for beginners. Internally, Python converts the source code into an intermediate form called bytecodes and then translates this into the native language of your specific computer and then runs it. You just run your programs and you never have to worry about linking and loading with libraries, etc.
Object-Oriented – Simple and additionally supports procedural programming
Extensible – easily import other code
Cross-platform language -Python can run equally on different platforms such as Windows, Linux, Unix , Macintosh etc. A Python program written on a Macintosh computer will run on a Linux system and vice versa. Thus, Python is a portable language .
Integrated –easily place your code in non-python programs
Extensive libraries -(i.e. reg. expressions, doc generation, CGI, ftp, web browsers, ZIP, WAV, cryptography, etc…) (wxPython, Twisted, Python Imaging library)
Databases Connectivity -Python provides interface to all commercial databases.
What can I do with Python…?
- System programming
- Graphical User Interface Programming
- Internet Scripting
- Component Integration
- Database Programming
- Gaming, Images, XML , Robot and more…..
•code or source code: The sequence of instructions in a program.
•syntax: The set of legal structures and commands that can be used in a particular programming language.
•output: The messages printed to the user by a program.
•console: The text box onto which output is printed. –Some source code editors pop up the console as an external window, and others contain their own console window.
Compiling and interpreting
Assembler, COBOL, PL/I, C/C++ are all translated by running the source code through a compiler. This results in very efficient code that can be executed any number of times. The overhead for the translation is incurred just once, when the source is compiled; thereafter, it need only be loaded and executed.
Interpreted languages, in contrast, must be parsed, interpreted, and executed each time the program is run, thereby greatly adding to the cost of running the program. For this reason, interpreted programs are usually less efficient than compiled programs.
How Python is interpreted?
An interpreter is a kind of program that executes other programs. When you writePython programs , it converts source code written by the developer into intermediate language which is again translated into the native language / machine language that is executed.
The python code you write is compiled into python bytecode, which creates file with extension .pyc . The bytecode compilation happened internally, and almost completely hidden from developer. Compilation is simply a translation step, and byte code is a lower-level, and platform-independent , representation of your source code. Roughly, each of your source statements is translated into a group of byte code instructions. This byte code translation is performed to speed execution byte code can be run much quicker than the original source code statements.
The .pyc file , created in compilation step, is then executed by appropriate virtual machines. The Virtual Machine just a big loop that iterates through your byte codeinstructions, one by one, to carry out their operations. The Virtual Machine is the runtime engine of Python and it is always present as part of the Python system, and is the component that truly runs the Python scripts . Technically, it’s just the last step of what is called the Python interpreter.