You are on page 1of 3

PYTHON EXERCISE:

Q.1.

>>> 29/5
5
>>> 29.0/5
5.8
>>> 2.5**4
39.0625
>>> 24**0.5
4.898979485566356

Q.2.

>>> import math


>>> x=math.pi/6
>>> t=math.sin(x)
>>> t
0.49999999999999994
>>> t=math.log(x)
>>> t
-0.6470295833786549
>>> t=math.tanh(x)
>>> t
0.4804727781564516
>>> t=math.cos(x)
>>> t
0.8660254037844387

Q.3.

c=input('temp in celcius=')
f=c*(9.0/5)+32
print 'temp in farrenheit=',f

temp in celcius=27
temp in farrenheit= 80.6

Q.4.
fname=raw_input('first name:')
lname=raw_input('last name:')
adline1=raw_input('adderess line 1:')
adline2=raw_input('adderess line 2:')
cy=raw_input('city:')
st=raw_input('state:')
pc=raw_input('pin code:')
pn=raw_input('phone number:')
print ('Name: '),fname,lname
print ('adderess:'),adline1,adline2
print ('city:'),cy,('state:'),st,('pin code:'),pc,
print('phone number:'),pn
first name:sanu
last name:gangwar
adderess line 1:IIT
adderess line 2:GANDHINAGAR
city:gandhinagar
state:gujrat
pin code:382355
phone number:9045526818
Name: sanu gangwar
adderess: IIT GANDHINAGAR
city: gandhinagar state: gujrat pin code: 382355 phone number: 9045526818

SYMPY EXERCISE:

Q.1.

from sympy import*


from sympy import symbols
x=symbols('x')
expr=tanh(x)
y=expr.series(x,0,16)
print y

x - x**3/3 + 2*x**5/15 - 17*x**7/315 + 62*x**9/2835 - 1382*x**11/155925 +


21844*x**13/6081075 - 929569*x**15/638512875 + O(x**16)

from sympy import*


from sympy import symbols
x=symbols('x')
expr=sin(x)
y=expr.series(x,0,16)
print y

x - x**3/6 + x**5/120 - x**7/5040 + x**9/362880 - x**11/39916800 + x**13/6227020800 -


x**15/1307674368000 + O(x**16)

Q.2.

>>> x,a=symbols('x a')


>>> integrate(x*sin(a*x), x)
Piecewise((0, a == 0), (-x*cos(a*x)/a + sin(a*x)/a**2, True))

>>> integrate((x**6)*sin(x),(x,0,2*pi))
-64*pi**6 - 1440*pi**2 + 480*pi**4

>>> integrate(exp(-x**2),x)
sqrt(pi)*erf(x)/2

You might also like