0% found this document useful (0 votes)
4 views20 pages

Introduction To Pythonjajsjdjdjs

The document provides an introduction to Python programming, covering fundamentals, installation procedures, and the execution of a simple Python program. It outlines the differences between Python 2 and Python 3, installation steps for various Python IDEs, and how to install Python modules. Additionally, it includes a sample program and homework assignments related to Python installation and basic programming concepts.

Uploaded by

tmcreatorspalace
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views20 pages

Introduction To Pythonjajsjdjdjs

The document provides an introduction to Python programming, covering fundamentals, installation procedures, and the execution of a simple Python program. It outlines the differences between Python 2 and Python 3, installation steps for various Python IDEs, and how to install Python modules. Additionally, it includes a sample program and homework assignments related to Python installation and basic programming concepts.

Uploaded by

tmcreatorspalace
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Outline Fundamentals Installation The first Python program

Introduction to Computing
Introduction to Python

Malay Bhattacharyya

Associate Professor

MIU, CAIML, TIH


Indian Statistical Institute, Kolkata
September, 2025

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

1 Fundamentals

2 Installation

3 The first Python program

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

The Python interpreter

Source code → (Python interpreter) → Executable

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

Standard versions of Python

Significant Features Python 2 Python 3


print As a statement As a function
xrange() Yes No
Returning lists Yes No
Returning iterable objects No Yes
Unicode No Yes
byte type No Yes
Exception handling with as No Yes
Integer division Traditional New

Note: Python 1 is no more in use and Python 2 is almost obsolete.

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

Python installation
On Windows:

On Linux:
$ sudo apt-get update
$ sudo apt-get install <python_version> (say python3.13.7)
$ python3 --version
Malay Bhattacharyya Introduction to Computing
Outline Fundamentals Installation The first Python program

Installing/updating Python modules (i.e., packages)


Installing a specific module:

python -m pip3 install <module> (e.g. math, pandas, numpy)

Installing a specific version of module:

python -m pip3 install <module> == <version>

Installing a specific module with a minimum version:

python -m pip3 install <module> >= <version>

Updating a specific module:

python -m pip3 install --upgrade <module>

Note: Installations/updates are to be done from the command


prompt (not from the Python environment).
Malay Bhattacharyya Introduction to Computing
Outline Fundamentals Installation The first Python program

Installing Spyder (An IDE for Python)

Source: https://www.spyder-ide.org (current version is 6.0.8)

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

Installing Visual Studio Code (An IDE for Python)

Source: https://code.visualstudio.com/Download (current


version is 1.103)

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

Installing Jupyter Lab

Installing JupyterLab 4.4.6:


https://jupyter.org/install.html

Installation with pip:

pip install jupyterlab

Running JupyterLab 4.4.6:

jupyter-lab

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

Installing Jupyter Notebook

Installing Jupyter Notebook:


https://jupyter.org/install.html

Installation with pip:

pip install notebook

Running Jupyter Notebook:

jupyter notebook

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

Using Jupyter Notebook in browser


Available at: https://jupyter.org
Open Jupyter Notebook in browser:
https://jupyter.org/try
Try Jupyter Notebook Application:

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

Installing modules (i.e., packages) on Jupyter Notebook

Installation in Jupyter shell:

!pip install <module> (e.g. xgboost)

Installation in Jupyter kernel:

import sys
!{sys.executable} -m pip install <module> (e.g. xgboost)

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

An important note

pip is generally connected with Python 2 on Linux and Mac,


whereas pip3 is connected with Python 3.

On the other hand, both pip and pip3 can be used to install
Python 3 packages on Windows.

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

The first Python program (in Python 3)

Source: Welcome2Python.py

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

The first Python program (in Python 3)

Source: Welcome2Python.py

print("Welcome 2 Python")

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

The first Python program (in Python 3)

Source: Welcome2Python.py

print("Welcome 2 Python")

Execution: Welcome2Python.py

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

The first Python program (in Python 3)

Source: Welcome2Python.py

print("Welcome 2 Python")

Execution: Welcome2Python.py
Welcome 2 Python(cursor here!!!)

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

Dissecting a code

# Import Statements
import math
# Function Definitions
def div(a, b):
return a/b # Note the indentation
# Statements
var1 = 3
var2 = 2
# Functions
division = div(var1, var2) # Function call
print(division) # Prints 1.5
print(not (division > math.pi)) # Prints True

Malay Bhattacharyya Introduction to Computing


Outline Fundamentals Installation The first Python program

Dissecting a code

# Import Statements
import math
# Function Definitions
def div(a, b):
return a/b # Note the indentation
# Statements
var1 = 3
var2 = 2
# Functions
division = div(var1, var2) # Function call
print(division) # Prints 1.5
print(not (division > math.pi)) # Prints True

Note: The program name can be anything.


Malay Bhattacharyya Introduction to Computing
Outline Fundamentals Installation The first Python program

Homework
Complete the installation of the latest version of Python on a
machine. Run the following program, note the output, and
understand its purpose.
import math
num = 111
if num < 2:
print(’Not a prime’)
else:
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
print(’Not a Prime’)
exit()
print(’Prime’)
Try installing the pandas module on a machine. Show the
installation report.
Malay Bhattacharyya Introduction to Computing

You might also like