Skip to content
Home » Running Python

Running Python

Below is a clear, complete, exam-oriented explanation of Running Python, covering all important methods: interactive mode, script mode, IDEs, command line, and editors. Suitable for BCA/MCA/B.Tech students.


Running Python

Once Python is installed, you can run Python programs in different ways depending on your requirement. Python provides two primary modes of execution:

  1. Interactive Mode (Python Shell / REPL)
  2. Script Mode (Running .py files)

Along with this, Python can also be run using:

  • IDLE
  • VS Code
  • PyCharm
  • Jupyter Notebook
  • Command Line Terminal

1. Running Python in Interactive Mode (Python Shell / REPL)

Interactive mode lets you execute Python commands line by line.
It is useful for:

  • Testing small code snippets
  • Learning Python
  • Checking output quickly

How to open Python Interactive Shell:

Windows:

Open Command Prompt and type:

python

macOS/Linux:

python3

You will see the Python prompt:

>>>

Example in interactive mode:

>>> print("Hello")
Hello
>>> 5 + 6
11

Exit interactive mode:

>>> exit()

or press Ctrl + Z (Windows) or Ctrl + D (macOS/Linux)


2. Running Python in Script Mode (Using .py Files)

Script mode is used for writing full Python programs in files ending with .py extension.

Steps:

  1. Open a text editor (Notepad, VS Code, Sublime, PyCharm, etc.)
  2. Create a file:
    example.py
  3. Write Python code: print("Python Script Mode Example")
  4. Save the file.

Run the file from Command Prompt/Terminal:

Windows:

python example.py

macOS/Linux:

python3 example.py

This executes the program and shows output.


3. Running Python Using IDLE

IDLE (Integrated Development and Learning Environment) comes bundled with Python.

To open IDLE:

  • Windows Start Menu → Search IDLE
  • macOS/Linux → depending on installation

IDLE provides:

  • Python shell (interactive mode)
  • Editor window (script mode)

Steps to run using IDLE:

  1. Open IDLE
  2. Click File → New File
  3. Write code: print("Hello from IDLE")
  4. Save (Ctrl + S)
  5. Run → Run Module (F5)

Output appears in Python Shell.


4. Running Python in VS Code

VS Code is one of the most popular editors.

Steps:

  1. Install VS Code
  2. Install the Python Extension
  3. Create a file with .py extension
  4. Write your code
  5. Click Run > Run Without Debugging
  6. Output appears in the terminal

5. Running Python in PyCharm

PyCharm is a dedicated Python IDE.

Steps:

  1. Install PyCharm
  2. Create a new project
  3. Create a Python file
  4. Write code
  5. Click the Run button

PyCharm automatically handles Python interpreter paths.


6. Running Python in Jupyter Notebook

Used in Data Science and Machine Learning.

Steps:

Run:

jupyter notebook

Create Python notebook:
File → New → Python 3

Write code inside cells and press Shift + Enter to execute.


7. Running Python Using Command Line Arguments

You can pass arguments to Python scripts.

Example script: add.py

import sys
print("Arguments:", sys.argv)

Run:

python add.py 10 20

Output:

Arguments: ['add.py', '10', '20']

8. Using “python -c” to run one-line commands

You can run quick commands without opening interactive mode:

python -c "print(5*5)"

Output:

25

9. Running Python Using an Online Compiler

If Python is not installed, you can use:

  • Replit
  • Google Colab
  • Jupyter Notebook online
  • Programiz / HackerRank / TutorialsPoint editors

Summary Table: Running Python

MethodDescriptionBest Use
Interactive modeRun line-by-line in Python shellTesting small code
Script modeRun .py filesFull programs
IDLEBuilt-in Python IDEBeginners
VS CodeEditor with extensionsMost common
PyCharmFull IDEProfessional development
Jupyter NotebookCell-basedData science
Terminal commandspython -cQuick tasks
Online compilersBrowser-basedNo installation required