Module I - Day 2

Python Made Easy: Science and Math Edition

Sep-Dec 2025 batch, Vikrant Patil

Date: 04 Oct 2025

Click here for All Notes

© Vikrant Patil

3 + 4 # shift enter will execute the cell code
7

this is markdown. in this just type text

4 * 5
20

Numbers and Text

  • integers
  • floats
4
4
2.5 # float
2.5
4 + 5
9
4 * 5
20
5 - 4
1
5 / 4  # this will compute division and return 
1.25
2.0 # flaot
2.0
2
2
4.5 * 4
18.0
4 + 5
9
4 * 5
20
6 / 2
3.0
6 // 2
3
5 // 2  # it will give only integer part of the division
2
5 ** 3
125
2**100
1267650600228229401496703205376
"vikrant"
'vikrant'
"poorva"
'poorva'
'samiha'
'samiha'
'hello'
'hello'
"sdgfd kjshdjgf 1212 232424"
'sdgfd kjshdjgf 1212 232424'
"""lets write a poem
which has some lines
which can be be like rhyme
thats ..this when i end the rhyme"""
'lets write a poem\nwhich has some lines\nwhich can be be like rhyme\nthats ..this when i end the rhyme'
4 + 5
9

“” is called as new line character “ is called tab

"one\ttwo"
'one\ttwo'

variables are names

a = 10 
a
10
a  + 1
11
name = "vikrant"
name
'vikrant'
fullname = "vikrant patil"
full_name = "vikrant patil"
2x = 20
  Cell In[38], line 1
    2x = 20
    ^
SyntaxError: invalid decimal literal
x2 = 20

rules for names of variables

  • it can be only alpha-numeric (it can have alphabets and numbers and _)
  • spaces, newlines, tabs, commas, special characters, any operator is not allowed
  • first character can not be number, but number can be there at any other place than first location

variables and literals

2 
2
x # because it is not a number, it looks like text ...but it is not text (because there is no quote!)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[41], line 1
----> 1 x # because it is not a number, it looks like text ...but it is not text (because there is no quote!)

NameError: name 'x' is not defined
a
10
x = 40 # assignment operator
x
40
y
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[46], line 1
----> 1 y

NameError: name 'y' is not defined
y = 30
y
30
poem = """lets write a poem
which has some lines
which can be be like rhyme
thats ..this when i end the rhyme"""
poem
'lets write a poem\nwhich has some lines\nwhich can be be like rhyme\nthats ..this when i end the rhyme'
name = "samiha"
name
'samiha'
name
'samiha'
peom
'lets write a poem\nwhich has some lines\nwhich can be be like rhyme\nthats ..this when i end the rhyme'
"one\ntwo\nthree" # not very user friendly
'one\ntwo\nthree'

Collections

  • list
odds = [1, 3, 5, 7, 9, 11]
odds
[1, 3, 5, 7, 9, 11]
x = 4
x
4
odss
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[63], line 1
----> 1 odss

NameError: name 'odss' is not defined
odds #list of integers
[1, 3, 5, 7, 9, 11]
students = ['poorva', 'samiha']
poorva = ['Poorva', 'Engineer', 'Pune'] # list of text data
samiha = ['Samiha', "Microbilogist", "Dapoli"] # list of text data
students = [poorva, samiha] # list of list
students
[['Poorva', 'Engineer', 'Pune'], ['Samiha', 'Microbilogist', 'Dapoli']]

dictionary

odds
[1, 3, 5, 7, 9, 11]
odds[0] # you can access items from list by a index which is a number
1
odds[1]
3
odds[2]
5
odds[5]
11
odds[6]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[77], line 1
----> 1 odds[6]

IndexError: list index out of range
odds[-1] # last items
11
odds[-2] # second last
9
poorva = {"name":"Poorva",
         "profession": "Engineer",
         "place": "Pune"}

samiha = {"name": "Samiha",
          "profession": "Microbiologist",
          "place": "Dapoli"}
odds[0]
1
poorva['name']
'Poorva'
poorva['profession']
'Engineer'
poorva['place']
'Pune'
students = [poorva, samiha]
students
[{'name': 'Poorva', 'profession': 'Engineer', 'place': 'Pune'},
 {'name': 'Samiha', 'profession': 'Microbiologist', 'place': 'Dapoli'}]
point1 = {"x" : 0,
         "y": 10}
origin = {"x": 0,
          "y": 0}
origin
{'x': 0, 'y': 0}
origin['x']
0

Problem 1.1 In mathematical notation, we can write an equation like v = u + at where v is final velocity of object and u is initial velocity, a is acceleration. (usually it is understood that we are multiplying a and t when a and t are written side by side. But that does not work in Python. You need to put * operator between a and t to make python understand that it need to multiply them! Make use of python to find out velocity of an object after 5 seconds, which is thrown straight up at velocity of 100m/s. Assume acceleration due to gravity is 9.8 m/s\(^2\)

u = 100 # initial velocity
a = -9.8
t = 5
v = u + a*t
v
51.0

Problem 1.2

Use python to find total income if the person has five income sources giving income of 123330, 250000, 45555, 232130, 11123

incomes = [123330, 250000, 45555, 232130, 11123]
incomes[0] + incomes[1] + incomes[2] + incomes[3] + incomes[4]
662138

Problem 1.3

Total amount after compound interest is calculated using formula P (1 + r/n)\(^n\)\(^t\) For this formula, P is the principal amount, r is the rate of interest per annum as fraction of 100, n denotes the number of times in a year the interest gets compounded, and t denotes the number of years. Use python to compute compound interest for principle amount of 26780, rate of interest 7%, interest is compounded 4 quarterly, and amount is invested for 5 years.

Problem 1.4

Have a look at following python statements. ::

x = 10
y = x
x = x + 10

What will be value of y?

Problem 1.5

What will be value of x after executing all statements?::

x = 10
y = x
y = 25
name = "samiha"
a = 10
b = 20
c = a + b