P = 26780
r = 0.07
n = 4
t = 5
P * ( 1 + r/n)**(n*t) # any execution of cell in jupyter will show result of last line 37887.76008234032
Sep-Dec 2025 batch, Vikrant Patil
Date: 04 Oct 2025
© Vikrant Patil
Problem 1.2
Total amount after compound interest is calculated using formula P (1 + r/n) \(^n\)\(^t\) . 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 Total amount after compoundin 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
37887.76008234032
1267650600228229401496703205376
objects that can not be modified once created
'This is some sentence'
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[47], line 1 ----> 1 text[0] = "T" TypeError: 'str' object does not support item assignment
['this', 'has', 'some', 'words', 'but', 'in', 'single', 'sentence']
['first line',
'second line',
'another line',
'yet another',
'and this ',
'is last one']
one,two,three,four,five
'one and two and three and four and five'
Help on built-in function find:
find(...) method of builtins.str instance
S.find(sub[, start[, end]]) -> int
Return the lowest index in S where substring sub is found,
such that sub is contained within S[start:end]. Optional
arguments start and end are interpreted as in slice notation.
Return -1 on failure.
just recollect the problem
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\)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[138], line 1 ----> 1 s NameError: name 's' is not defined
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[141], line 1 ----> 1 add NameError: name 'add' is not defined
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[147], line 1 ----> 1 add(50) TypeError: add() missing 1 required positional argument: 'b'
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[148], line 1 ----> 1 add() TypeError: add() missing 2 required positional arguments: 'a' and 'b'
def compute_velocity(initial_velocity, acceleration, time):
"""Compute velocity using newton's law of motion.
computes final velocity given initial velocity , acceleration and time
initial_velocity -> velocity in m/s
acceleratin -> acceleration in m/s**2
time -> time in seconds
returns -> final velocity in m/s
"""
v = initial_velocity + acceleration*time
return vHelp on function compute_velocity in module __main__:
compute_velocity(initial_velocity, acceleration, time)
Compute velocity using newton's law of motion.
computes final velocity given initial velocity , acceleration and time
initial_velocity -> velocity in m/s
acceleratin -> acceleration in m/s**2
time -> time in seconds
returns -> final velocity in m/s
problem Write a function compound_interest which takes arguments P, r, n, t where P is principle amount, r is rate of interest in %, n is componding frequency, t is time in years. compound interest is calculated using formula P (1 + r/n)\(^n\)\(^t\) - P
# header
## header2
### header
**text** bold
`code` code
$latex$
text code
Write a function say_hello which will take one argument called name and print hello greeting with that name. for example look at following example of a sample function call
[ ]: say_hello("vikrant")
Hello Vikrant!Here is a list of some built in functions , which means you don’t have to define them, they exist with python installation (we have seen few such functions e.g. print, type). Try them out by passing appropriate arguments as suggested.
len : finds length of a list/text like objects. len([1, 1, 2, 2, 3, 3]) will give 6 as result. len(“hello”) will give 5.sum : finds sum of numbers from a list (if has all numbers in it). So you pass a desired list as argument to sum.e.g. sum([1,2,3]) will result into 6!str : converts an integer or float to text format, so that every digit in the number becomes a text characterint : converts a text into a number for example if you want to make “1234” as 1234 use int("1234")Now write a function mean which will finds out arithmatic mean of numbers given in a list. A function mean will have an argument numbers which is assumed to be a list. your function will compute mean of numbers from that list. here is one sample run of function.
[ ]: mean([1,2,3,4,5])
3.0Write a function count_digits which will count how many digits are there in an integer. So this function will take an argument n which is assumed to be an integer. Your function will return number of digits it has. Here are few sample runs
[ ]: count_digits(45)
2
[ ]: count_digits(10000)
5