You are on page 1of 2

Computational Mathematics with SageMath

Ajit Kumar @ ICT Mumbai


Lecture 1

1 Introduction to Python
1.1 Mathematical Operations

[ ]: print("Hello World!")

[ ]: print('Hello World!')

[ ]: 'Hello World!'

[ ]: 6834 + 57

[ ]: 6834 * 57

[ ]: 6834 / 57

Quotient-Remainder calculations
[ ]: 6834 // 57 # Returns quotient

[ ]: 6834 % 57 # Returns the remainder

[ ]: a = 6834
b = 57

[ ]: print(a,b)

[ ]: q = a//b
r = a%b
print(q,r)

[ ]: b*q+r == a

[ ]: 27**5

1
[ ]: 27**50

[ ]: 27**500

[ ]: 27**10000

[ ]: 27**100000

[ ]: 27**(0.5)

[ ]: P = 20000
r = 5.5
t = 5
Amount1 = P+ P*r*t/100
Amount2 = P*(1+ r/100)**t
print(Amount1)
print(Amount2)

Suppose we want to print:


The return with simple interest at 5.5% after 5 years is 25500.
We can use ‘print’ function with F-string

[ ]: print(f'The return with simple interest at {r}% after {t} years is Rs.{Amount1}.
,→')

[ ]: print(f'The return with compound interest at {r}% after {t} years is Rs.
,→{Amount2}.')

[ ]: print(f'The return with compound interest at {r}% after {t} years is Rs.{Amount2:
,→6f}.')

[ ]: print(f'The return with compound interest at {r}% after {t} years is Rs.{Amount2:
,→.10}.')

You might also like