Python Working Mode – Interactive Mode and Script Mode

In this chapter Python Working Mode, we will learn about the two working modes of Python: Interactive Mode and Script Mode. We will understand what they are, their features, and when to use each mode.

In the previous chapter, we learned that before writing Python programs, we need to install Python on our computer. The Python installation package includes the Python Interpreter, IDLE (Integrated Development Environment), and Python Standard Libraries. Among these, we mainly use Python IDLE to write and run Python programs.

Python IDLE Interface and Its Features

When you open Python IDLE, you will see a simple and user-friendly interface. The main components of Python IDLE are:

  • Python Shell (Interactive Mode)
  • Editor (Script Mode)
  • Debugger

Interactive Mode (Python Shell)

  • Interactive Mode opens by default when IDLE is started.
  • In this mode, commands are entered in the Python Shell.
  • It enables users to enter Python commands and see the results immediately.
  • The Python Shell is an interactive interface that allows users to communicate directly with the Python Interpreter.  
  • It is convenient for learning Python, performing quick calculations, and testing small pieces of code.
  • When the Python Shell is opened, the following prompt appears: >>> 
  • This prompt indicates that the Interpreter is ready to accept commands.

Example:

Script Mode

  • In this mode, a complete program is written in the Editor Window.
  • A Code Editor is a tool used to write and save program code.
  • The program is saved as a Python file (.py).
  • The entire program is executed at once when it is run.
  • It is convenient for creating longer and more complex programs.
  • To work with Script mode, click on File -> New File

Python Script/Program: Python statements written in a particular sequence to solve a problem is known as Python Script/Program.

Working in Script Mode

To write a Python program in Script Mode:

  1. Click File → New File to open a new Editor Window.
  2. Type the Python statements required to solve the problem.
  3. Save the program using File → Save and give it a meaningful name.
  4. Run the program using Run → Run Module.
  5. The output of the program will be displayed in the Python Shell.

Understanding First Python Program:

  • # Python First Program is a comment used to describe the purpose of the program. Comments are ignored during program execution.
  • print(“techtipnow.in”) displays the text cbsesolutions.in on the screen.
  • print() is a built-in Python function used to display output.
  • name = “python” creates a variable named name and stores the string value “python” in it.
  • print(name) displays the value stored in the variable name.
  • X = 23 and Y = 34 assign the integer values 23 and 34 to the variables X and Y respectively.
  • print(“Total =”, X + Y) calculates the sum of X and Y and displays the result along with the text “Total =”.
  • The + operator is an arithmetic operator used to add two numbers.

Leave a Comment

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

error: Content is protected !!
Scroll to Top