2 Modes of Python | Interactive and Script mode

In Python, Programs can be written in two possible ways namely

  • Interactive mode
  • Script mode

How to Open python in Windows OS

  • Start → All Programs → Python 3.x → IDLE (Python 3.9)

Interactive Mode Programming

The Interactive mode or Interpreter mode provides programmers a quick way to execute commands without creating a python file (without .py). It is most convenient for the user who is working on small projects.

python virtual example

In this Interpreter mode, we can be written directly and have instant results for simple programs. This mode is also called a “Simple Calculator”. This mode allows the command prompt >>> to write codes. We can do many calculations like addition, subtraction, multiplication, division not only for calculations it has many features. You can understand clearly with the below examples.

python virtual example

Script Mode

whereas in script mode programs can be written and stored as a separate file with the extension .py and executed. This code can be editing and reusability code. Once a script is created it can be reusable without retyping it is more useful for modular programming – A big program is divided into smaller modules. It is used for finding errors easily and modify quickly.

Steps to follow in Script mode

  • Select File → New File or press Ctrl + N on the left side File Option.

After that one blank space is displayed called a script text editor. You can type code in that script text editor like below

python virtual example

After type a code you need to save a file. In the above image, I wrote some code for beginners to understand easily. print() functions return whatever you have written inside in parentheses. For example, print(“Hello world!”) gives Hello world! in results. we will learn about this in upcoming blogs

  • Saving Python Script.

Select File → Save or Press Ctrl + S after that one save as box is appear on the screen like that above image. choose your specific folder to save a python file and give a file name without .py because python takes default .py when you save a file.

  • Run a interpreter or give F5

Then run a code is given as an exact result. If suppose a code is not executed and thrown some error means checking a code once and corrected the mistake was down in that code after it will execute successfully without errors. Like this

python virtual example

My Previous Posts

How to install python check it: https://iterathon.tech//how-to-install-python-3-x-in-windows-and-linux/

LEARN LITTLE BY LITTLE TO CHANGE THE TECH WORLD

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *