CMSM Lecture2 Handouts
CMSM Lecture2 Handouts
[ ]: import math
[ ]: math.sqrt(2)
[ ]: math.sin(2.5)
[ ]: math.asin(-0.75)
[ ]: math.gcd(34352, 88262)
[ ]: help(math.log10)
[ ]: n = 20
r = 12
perm(n,r)
comb(n,r)
[ ]: perm(n,r)==factorial(n)/factorial(n-r)
[ ]: comb(n,r) == factorial(n)/(factorial(r)*factorial(n-r))
1
[ ]: sqrt(4)
[ ]: import cmath
[ ]: dit(cmath)
[ ]: cmath.sqrt(-1)
[ ]: z = 5+3j
cmath.sqrt(z)
[ ]: a, b, c = 3, 5, -7
x1 = (-b+sqrt(b**2-4*a*c))/(2*a)
x2 = (-b-sqrt(b**2-4*a*c))/(2*a)
print(f'The roots are {x1} and {x2}')
[ ]: a
[ ]: a
[ ]: a = float(input('Enter a:'))
b = float(input('Enter b:'))
c = float(input('Enter c:'))
s = (a+b+c)/(2.0)
A = sqrt(s*(s-a)*(s-b)*(s-c))
print(f'The area is given by {A:.4}')
print(f'The area is given by {A:.4f}')
[ ]: factorial(100)
2
[ ]: factorial(1000)
4 Practice Execrcises
1. Write python codes to input radius of a shpere and print its surface area and volume.
2. Input a positive integer n and intger k <= n. Verify the following properties
i. n Ck = n Cn−k
ii. k × n Ck = n × n−1 Ck−1
iii. n Ck−1 + n Ck = n+1 Ck
3. Input a complex number z and explore some of the properties of z.
[ ]: