MCS-201 · Unit 9

Introduction to Python

Section 7 of 7

Block 3 · Unit 9Introduction to Python11 min · Section 7 of 7

9.7Getting Started and Running Your First Program

Covers IGNOU MCS-201 §9.5, 9.7

Now it is time to run Python yourself. This section explains how to install it, which tools to write code in, the two ways of running code, and your first programs.

Installing Python

SystemHow
WindowsDownload the installer from python.org; tick “Add python.exe to PATH” on the first screen
macOSDownload the installer from python.org (or use Homebrew: brew install python)
LinuxPython 3 is usually pre-installed; otherwise use the package manager, for example sudo apt install python3
No installationUse Google Colab in a web browser

Install the latest Python 3 release (Python 3.15 was released in October 2026; any recent 3.x version is fine for this course). Check the installation in a terminal:

Checking the installation
$ python3 --version
Python 3.15.0

On Windows the command is usually python or py; on macOS and Linux it is python3.

Where to write code

ToolWhat it isGood for
IDLESimple editor and shell installed with PythonFirst steps
VS CodeFree code editor with a Python extensionGeneral programming; debugging
PyCharmFull Python IDE (free Community edition)Larger projects
Jupyter Notebook / JupyterLabBrowser-based notebooks of code cells, text and chartsData science, experiments
SpyderScientific IDE with a variable explorerData analysis, MATLAB-like work
AnacondaA distribution: Python plus hundreds of data-science packages and tools like Jupyter and SpyderData science on your own machine
Google ColabFree hosted Jupyter notebooks in the browser, with NumPy, pandas and others preinstalledNo installation; using a GPU

An IDE (Integrated Development Environment) combines an editor, a way to run programs, and a debugger in one application.

Interactive mode and script mode

Interactive mode (shell, REPL)Script mode
StartType python3 in a terminal, or open IDLESave code in a .py file and run python3 file.py
Prompt>>>None
ResultsThe value of each expression is shown automaticallyOnly what print outputs is shown
Kept?No, lost when you exitYes, saved in the file
Use forTrying ideas, quick calculationsReal programs

REPL stands for Read–Eval–Print Loop: the shell reads an expression, evaluates it, prints the result and waits for the next one.

An interactive session
$ python3
>>> 2 + 3 * 4
14
>>> name = "Nav"
>>> name.upper()
'NAV'
>>> exit()

Key takeaways

  • Install the latest Python 3 from python.org, or use Anaconda or Google Colab.
  • Interactive mode (>>>) is for experiments; script mode runs saved .py files.
  • Jupyter and Colab run code cell by cell.
  • print() shows output; input() reads text, which must be converted for numbers.

Practice questions

Answer on paper first, then check. The explanation matters more than the letter you chose.

Question 1 · multiple choice

What does >>> indicate?

Show answer

Answer: C. The prompt of the Python interactive shell

The REPL shows >>> when it is waiting for you to type a statement or expression.

Question 2 · multiple choice

How is a saved program report.py run from a terminal on macOS or Linux?

Show answer

Answer: B. python3 report.py

The interpreter is given the file name as an argument; there is no separate compile step.

Question 3 · multiple choice

What does this program print if the user enters 7?

Python · quiz_input.py
n = input("Number: ")
print(n * 2, int(n) * 2)
Show answer

Answer: C. 77 14 (after the prompt “Number: ”)

input() returns the string “7”; multiplying a string by 2 repeats it (“77”), while int(n) * 2 is 14.

Question 4 · multiple choice

Which statement about Jupyter notebooks is correct?

Show answer

Answer: D. They run code one cell at a time, and a cell can hold many lines

A cell is the unit of execution; outputs, including charts, appear below each cell.

Question 5 · multiple choice

What is Anaconda?

Show answer

Answer: B. A distribution that bundles Python with data-science packages and tools such as Jupyter and Spyder

Anaconda packages Python with many libraries and tools, saving you from installing them one by one.

Question 6 · short answer

Write a program that asks for the length and breadth of a rectangle and prints its area, and explain why the conversion is needed.

Show worked answer

length = float(input("Length: ")), breadth = float(input("Breadth: ")), print("Area =", length * breadth). input() always returns a string, and multiplying two strings is not allowed (TypeError), so each value is converted with float() (or int() for whole numbers) before the calculation. For inputs 5 and 3 the program prints Area = 15.0.

↑ ↓ move↵ openTab switch type