Module I - Day 1

Python Made Easy: Science and Math Edition

Sep-Dec 2025 batch, Vikrant Patil

Date: 20 Sep 2025

Click here for All Notes

© Vikrant Patil

Installation

Before we start programming, let’s get ready with the tools that we need for python programming. We will need python with appropriate version installed on our system. Throughout the tutorial we will be using python 3.11 or more. You can install python basic from python.org or you can get a python from anaconda with a whole bunch of packages default with it.

First Steps - Running python

There are various ways you can run python. Simplest option is to go to commandline tool of your system. For Linux and Mac Os it is terminal, for Windows it is cmd. Open up commandline , type python and enter. if this opens python terminal as given below then you have python properly installed and it in system path.

Python 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

if it does not then possibly your python executable is not put in system path by the installer. now in this case you can locate where the python is installed. it is mostly at

C:\Users\<YourUsername>\AppData\Local\Programs\Python\Python<XY>\

Where is your Windows username and represents the major and minor version of Python (e.g., Python311 for Python 3.11.

Creating virtual environment

To create virutal environment on your system, what you need is python version > 3.5. Python comes with a package called venv (virtual environment). For older python, virtualenv was seperate application. We are going to work with virtual environment that comes with python 3. Easy steps to work with it are as given below. Open up terminal on linux/mac or cmd terminal on windows. on the prompt type following command to create virtual environment with name env1

  python -m venv env1

This will create a folder with name env1 in the current directory. On linux it will have following contents

  +-env1
    |
    +-bin
    +-include
    +-lib
    +-lib64
    +-pyenv.cfg

on windows system it will have following contents

  +-env1
    |
    +-Include
    +-Lib
    +-Scripts
    +-pyenv.cfg

To activate virtual environment on linux run following command on terminal

bash$ source env1/bin/activate
(env1) bash$ # you can see the env1 environment activated as change in prompt

To activate virtual environment on windows run following command on windows cmd terminal::

C:\Users\vik> env1\bin\activate.bat
(env1) C:\Users\vik>

Installing jupyter in virtual environment

Once the virtul environment is created and activated, we are ready to use it. To install packages in this active virtual environment use pip install

pip install jupyterlab

after the installation is over run following command from terminal

jupyter-lab

This will launch juputer lab in a browser.

Working with jupyter notebook

Another fancy way of programming in python is jupyter notebook. once you launch jupyter from console or from start menu, a browser will be launched. Create a new notebook. To work with notebook you need to know few key strokes.

  ===========   ====================================
  keys          action                              
  ===========   ====================================
  esc+m         convert the cell to markdown        
  esc+y         convert the cell to code            
  shift+enter   execute the cell  current cell and create new code cell                 
  !command      execute system command from jupyter 
  ===========   ====================================

What is Programming?

Consider following sentences in different languages.

  • दोन आणि पाच यांचा गुणाकार करा आणि आपल्या नोटबुकमध्ये उत्तर लिहा
  • రెండు మరియు ఐదు గుణించి, మీ నోట్‌బుక్‌లో ఫలితాన్ని రాయండి
  • இரண்டு மற்றும் ஐந்தைப் பெருக்கி, உங்கள் நோட்புக்கில் முடிவை எழுதுங்கள்
  • બે અને પાંચને ગુણાકાર કરો અને તમારી નોટબુકમાં પરિણામ લખો
  • দুই এবং পাঁচটি গুণান এবং আপনার নোটবুকের ফলাফল লিখুন
  • दो और पांच गुणा करें और अपनी नोटबुक में परिणाम लिखें
  • multiply two and five and write result in your notebook

When you read it what do you do? These are instructions for you to think and act. Similarly ‘programs’ are instructions for computer to think and act. Languages that humans speak have wide spectrum right from very primitive to advanced one. Similarly computers also have wide spectrum of languages primitives to advanced. Instructions in humans language can be rigorous and plenty to do simple tasks. And there can be few elegant and poetic sentences which can inspire people to think and act in complicated and challenging scenarios. Here we are going to learn poetic, pythonish way of writing programs which will inspire machines to do seemingly complicated jobs.

Where should I use python

  • You want to do quick prototyping
  • Readable, human undersstandable code
  • lot of data/text processing / visualisation
  • web application
  • wrappers over low level languge
  • scripting - you don’t have compilation cycle, you can quickly run the program, get feedback fix the code.
  • very nicely glued to operatiing system operations, javascript libraries (for web based applications!)
  • Where efficiency is not bottleneck (rust/c/c++/assembly + wrap it with python if you want readability)

Numbers Text

To convert practical problem to computationally solvable format we need to define the problem such that computer understands it. We have a hierarchy of syllables, words, sentences, grammar , paragraphs in human languages in human languages. Similarly there are some words, syntax and some abstractions equivalent to sentences, paragraphs in computer programming languages.

Very primitive way of looking at Programming is manipulating numbers and text. To manipulate numbers and text we need to have some way of representing numbers and text in python. To manipulate numbers python has got basic numeric compabilities. Python interpreter can be directly used as calculator::

2 + 3
5

This is text cell

type text

2 + 3 # this is comment and this code is going to add 2 and 3
5

In numeric data there are two main basic datatypes, integer and float (real numbers). any data has to be worked with operator in order to do some computation

5 * 3 # here * is operator and 5 and 3 are integers
15
5 + 5 # result of two integers is integers!
10
5 + 5.0 # then I will get float
10.0
2 ** 100 # 2 raised to power 100
1267650600228229401496703205376
2 ** 400
2582249878086908589655919172003011874329705792829223512830659356540647622016841194629645353280137831435903171972747493376
5 / 2 # will result into float
2.5
5 // 2 # integer division take only whole division
2
2 * 2 *2 *2 *2 
32
2 **5
32

basic units in python

  • integers
  • float
  • text

operations

+
-
*
/
//
**
  • way to store data
  • ways to compbine basic opeartions and from complicated ..fucntions
x = 5
x + 3 # this give some more power
8
x = 10 # after this just enter (not shift enter)
y = 15
z = x + y # after this shift enter or play button
z 
25

text

name = "vikrant" # you can have at start and end double quote
name
'vikrant'
anothername = 'mohini' # start with single quote and en dwith single quote
anothername
'mohini'
student = siddharth # this is not text! 
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[25], line 1
----> 1 student = siddharth # this is not text! 

NameError: name 'siddharth' is not defined

if you don’t give quote, it will be treated as variable name

student = "siddharth"
poem = """This is title of my poem
this is where it starts
this yet another line from poem
it ends here"""
poem
'This is title of my poem\nthis is where it starts\nthis yet another line from poem\nit ends here'
poem # show me the internal representation of python data
'This is title of my poem\nthis is where it starts\nthis yet another line from poem\nit ends here'
print(poem)
This is title of my poem
this is where it starts
this yet another line from poem
it ends here

In text you can have multiline text, you can have spaces in it, you can have tabs in it.