Module I - Day 2

Python Made Easy: Science and Math Edition

Sep-Dec 2025 batch, Vikrant Patil

Date: 27 Sep 2025

Click here for All Notes

© Vikrant Patil

Numbers and text

  • integers
  • floats
  • text
a = 5
a
5
name = "vikrant"
name
'vikrant'
x = 5
z = x + a # here you won't see any prompt, because operation done is compute and save
5*4 + 10  # 5*4 will be executed first and + will be exuxted later
30
z
10
print(z)
10
1000
1000

collections

list

nums = [1,3, 5, 7, 9, 11]
nums
[1, 3, 5, 7, 9, 11]
students = ["Anil", "Pallavi", "Siddharth"]
students
['Anil', 'Pallavi', 'Siddharth']
evens = [2, 4, 6, 8]
odds = [1, 3, 5, 7]
allnums = evenv + odds # this will cancatenate two lists that were added using + operator
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[17], line 3
      1 evens = [2, 4, 6, 8]
      2 odds = [1, 3, 5, 7]
----> 3 allnums = evenv + odds # this will cancatenate two lists that were added using + operator

NameError: name 'evenv' is not defined
evens = [2, 4, 6, 8]
odds = [1, 3, 5, 7]
allnums = evens + odds # this will cancatenate two lists that were added using + operator
allnums
[2, 4, 6, 8, 1, 3, 5, 7]
odds + evens
[1, 3, 5, 7, 2, 4, 6, 8]
mixed = ["some","words", 2, 3, "it", "can", "have", "both", 42]
mixed
['some', 'words', 2, 3, 'it', 'can', 'have', 'both', 42]

access pattern

nums
[1, 3, 5, 7, 9, 11]
nums[0]  # get me 0th item
1
nums[1]
3
nums[2]
5
nums[3]
7
nums[4]
9
nums[5]
11
nums[6] # you can't exceed the size of list
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[32], line 1
----> 1 nums[6] # you can't exceed the size of list

IndexError: list index out of range
nums[-1] # last item
11
nums
[1, 3, 5, 7, 9, 11]
nums[-2]
9
nums[-6]
1
text = "This is some text data with some words"
text[0]
'T'
text[5]
'i'
text[4]
' '
sentence = "He said, 'I am fine!'"
sentence
"He said, 'I am fine!'"
sentence[7]
','
a + x
10
test = [1, 2, 3, 4, 5]
test
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[47], line 1
----> 1 test

NameError: name 'test' is not defined
students = [ a, b, c, d, e] # because a, b, c, d, e are not quoted! they are taken as variable names
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[48], line 1
----> 1 students = [ a, b, c, d, e] # because a, b, c, d, e are not quoted! they are taken as variable names

NameError: name 'b' is not defined

rename the list

allbirds = ["bulbul", "sparrow", "crow", "peacock"]
allbirds
['bulbul', 'sparrow', 'crow', 'peacock']
allbirds_one = allbirds # give new name
allbirds_one
['bulbul', 'sparrow', 'crow', 'peacock']
allbirds
['bulbul', 'sparrow', 'crow', 'peacock']
allbirds = ["small bird", "big bird", "very large bird"]
x = 10
y = x
x = 20
y
10
Name = "vikrant"
name = "Siddharth"
Name
'vikrant'
name
'Siddharth'

rules about variable names

  • variables can be only alphanumeric
  • can not start wit number
  • can end with or in between there can be number
  • there can not be space , comma, special char (oparators) in the name
  • case sensitive

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\)

Problem 1.2

Total amount after compound interest is calculated using formula P (1 + r/n) . In this formula, P is the principal amount, r is the rate of interest (as fraction of 100) per annum, 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.3

Have a look at following python statements.

x = 10
y = x
x = x + 10

What will be value of y after this?

Problem 1.4

What will be value of x after executing all statements?

x = 10
y = x
y = 25
u = 100
a = -9.8
t = 5
v = u + a*t
print(v)
51.0