Home | | Problem Solving and Python Programming | Modes of Python Interpreter

Chapter: Problem Solving and Python Programming : Data, Expressions, Statements

Modes of Python Interpreter

It uses 2 modes of Execution. 1. Interactive mode 2. Script mode

MODES OF PYTHON INTERPRETER:

 

Python Interpreter is a program that reads and executes Python code. It uses 2 modes of Execution.

 

1.              Interactive mode

2.              Script mode

 

1. Interactive mode:

 

v   Interactive Mode, as the name suggests, allows us to interact with OS.

v   When we type Python statement, interpreter displays the result(s) immediately.

 

Advantages:

v   Python, in interactive mode, is good enough to learn, experiment or explore.

v   Working in interactive mode is convenient for beginners and for testing small pieces of code.

 

Drawback:

v   We cannot save the statements and have to retype all the statements once again to re-run them.

 

In interactive mode, you type Python programs and the interpreter displays the result:

>>>     1 + 1

2

The chevron, >>>, is the prompt the interpreter uses to indicate that it is ready for you to enter code. If you type 1 + 1, the interpreter replies 2.

>>>     print ('Hello, World!')

Hello, World!

This is an example of a print statement. It displays a result on the screen. In this case, the result is the words.



 

2. Script mode:

 

v   In script mode, we type python program in a file and then use interpreter to execute the content of the file.

 

v   Scripts can be saved to disk for future use. Python scripts have the extension .py, meaning that the filename ends with .py

 

v   Save the code with filename.py and run the interpreter in script mode to execute the script.



 

Integrated Development Learning Environment (IDLE):

v   Is a graphical user interface which is completely written in Python.

v   It is bundled with the default implementation of the python language and also comes with optional part of the Python packaging.

 

Features of IDLE:

Multi-window text editor with syntax highlighting.

v   Auto completion with smart indentation.

Python shell to display output with syntax highlighting.


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Problem Solving and Python Programming : Data, Expressions, Statements : Modes of Python Interpreter |

Related Topics

Problem Solving and Python Programming : Data, Expressions, Statements


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.