Docsity

Basic python question and answers, Exercises of Computer Science

Toggle sidebar
bg1
Q) Write python keywords from the following list of words : And Class PASS if exec
PRINT Not.
ans) class, if
Q) write python statements for the following equations :
(a) rootl= -b+โˆš( b^2-4ac)/2a
=> root1 = (-b+math.sqrt (b**2-4*a*c))/2*a
(b) result = ((2xy-9y)/2xy^3)-((4yx^2)/2y) => result = ((2*x*y-9*y)/2*x*y**3)-( (4*y*x**2)/2*y)
(c) result = 2cos1/2 (x+y) cos1/2 (x-y) +e^x-1-x/4+tan (x) -log (v)
=> result = 2*math.cos (0.5 (x+y)) *math.cos(0.5 (x y)) +math.exp (x)-1-x/4+math.tan (x)
-math.log (v)
Q) how does the effect of the following two statements differ :
(a)x+=x+10
=> it is equivalent to x=x+x+10. for example: if x=2, output will be x=14.
(b)x=x+10
=> it is equivalent to x=x+10. for example: if x=2, output will be x=12.

Partial preview of the text

Download Basic python question and answers and more Exercises Computer Science in PDF only on Docsity!

Q) Write python keywords from the following list of words : And Class PASS if exec PRINT Not. ans) class, if

Q) write python statements for the following equations :

(a) rootl= -b+โˆš( b^2-4ac)/2a => root1 = (-b+math.sqrt (b2-4ac))/2*a

(b) result = ((2xy-9y)/2xy^3)-((4yx^2)/2y) => result = ((2xy-9y)/2xy3)-( (4yx2)/2y)

(c) result = 2cos1/2 (x+y) cos1/2 (x-y) +e^x-1-x/4+tan (x) -log (v) => result = 2*math.cos (0.5 (x+y)) *math.cos(0.5 (x y)) +math.exp (x)-1-x/4+math.tan (x) -math.log (v)

Q) how does the effect of the following two statements differ :

(a)x+=x+ => it is equivalent to x=x+x+10. for example: if x=2, output will be x=14.

(b)x=x+ => it is equivalent to x=x+10. for example: if x=2, output will be x=12.