You are on page 1of 3

Q.1.

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

Q.2.

>>> import math


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

Q.3.

t=input("temp(C)=")
f=t*(9.0/5)+32
print 'temp(F)=', f

temp(C)=27
temp(F)= 80.6
Q.4.

fname=raw_input('First name=')
lname=raw_input('Last name=')
adline1=raw_input('Address line1=')
adline2=raw_input('Address line2=')
dst=raw_input('District=')
stt=raw_input('State=')
pc=raw_input('Pincode=')
mbl=raw_input('Mobile no.=')
print 'name=' , fname , lname
print 'Address=' , adline1 , adline2 , dst , stt
print 'Pincode=' , pc
print 'Mobile=' , mbl
First name=Shubham
Last name=Garg
Address line1=D-534, duven
Address line2=IIT gandhinagar,
District=Gandhinagar
State=Gujarat
Pincode=235538
Mobile no.=904535264
name= Shubham Garg
Address= D-534, duven IIT gandhinagar, Gandhinagar Gujarat
Pincode= 235538
Mobile= 904535264

SYMPY exercise

Q.1.

>>> import sympy


>>> from sympy import *
>>> from sympy import symbols
>>> x=symbols('x')

a)
>>> y=sin(x)
>>> y.series(x,0,16)
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)

b)
>>> y=tanh(x)
>>> y.series(x,0,16)
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)
Q.2.

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

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

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

You might also like