Python Funda Practice Questions
Python Funda Practice Questions
1. From the following, find out which assignment statement will produce an error. State reason(s)
too. (2)
(a) x = 55
(b) y = 037
(c) z = 0o98
(d) 56thnumber = 3300
(e) length = 450.17
(f) !Taylor = 'Instant'
(g) this variable = 87.E02
(h) float = .17E - 03
(i) FLOAT = 0.17E – 03
ANSWER
ANSWER
(i) temperature = 90
print (temperature)
(ii) a = 30
b=a+b
print (a, b)
(iii) a, b, c = 2, 8, 9
print (a, b, c)
c, b, a = a, b, c
print (a, b, c)
(iv) X = 24
X=4
(v) ‘X’ is not defined
(vi) “else” Keywords cannot be used as identifiers
3. What will be the output produced by following code fragment (s)? (3)
ANSWER
(i) 15
13 22
(ii) 235
10 3 30
(iii) Side 7 - 7 49
ANSWER
i)Indentation is present in print statement.
ii) String and number cannot add.
iii) String and numbers cannot divide.
(a) >>> type(0) (b) >>>type(int(0)) (c) >>>.type(int('0')) (d) >>> type('0')
(e) >>>type(1.0) (f) >>>type(int(1.0)) (g) >>>type(float(0)) (h) >>>type(float(1.0))
(i) >>>type(3/2)
ANSWER
(a) <class 'int'> (b)<class 'int'> (c) Error (d) <class 'str'>
(e) <class 'float'> (f)<class 'int'> (g) <class 'float'> (h) <class 'float'> (i) <class 'float'>
a, b, c = 10, 20, 30
p, q, r = c-5, a +3, b - 4
print ('a, b, c :', a, b, c, end = '')
print ('p, q, r : ', p, q, r)
ANSWER
a, b, c : 10 20 30 p, q, r : 25 13 16
9. Write a program to obtain principal amount , rate of interest and time from user and compute simple
interest. (2)
10. Write a program to input the radius of a sphere and calculate its volume. (2)
(V=4/3 πr3)
rad = int (input("Enter the radius :-"))
volume = (4/3) * 3.14 * rad ** 3
print ("Volume = ", volume)