Home
MCQS
Python MCQ Quiz Hub
Python Functions MCQS Set 2
Choose a topic to test your knowledge and improve your Python skills
1. Write the output of : print(float())
1.0
0.0
Any floating number
Any integer
2. What type of error is returned by following statement? print(int(“a”))
Syntax error
ValueError
TypeError
Name Error
3. Write the output of the following: if user entered 7 a=input("Enter age") print(type(a))
str
int
float
None of the above
4. Write the output of the following: print(max(2, 5, 4, 8, 29, 24))
Error as there should be math.max( )
29
2
2 5 4 8 29 24
5. Write the output of the following: print(min(“Hell”, “Hello”, “he”))
Hell
he
Hello
Error
6. Write the output of the following. print(abs(-8))
-8
8
8.0
None of the above
7. Write the output of the following : print(round(34.5671,2)) print(round(34.3631,2))
34.57 34.36
34.56 34.37
34.57 35.36
36.00 34.36
8. Write the output of the following: print(list(i * 2 for i in range(4))) print(list(range(4)))
[0, 2, 4, 6] [3]
[0, 2, 4, 6] [0, 1, 2, 3]
[0, 1, 2, 3] [0, 1, 2, 3]
None of the above
9. Write the output of : print((range(5)))
range(0, 5)
0, 1, 2, 3, 4
[0, 1, 2, 3, 4]
Error
10. Which of the following mathematical function return absolute value of a number?
absolute( )
abs( )
perfect( )
absl( )
11. Which of the following Python module need to be imported to invoke sin( ) function?
math
Maths
mathematics
None of the above
12. Which of the following module which need to be imported to invoke randint( ) function?
randoms
random
random( )
None of the above
13. Which of the following mathematical function return factorial of a number?
fact( )
facto( )
factorial( )
fct( )
14. Name the function required to check if a string contains only uppercase letters?
upper( )
isup( )
isupper( )
iscapital( )
15. Which of the following function returns the length of a sequence?
len( )
length( )
lenseq( )
None of the above
16. Which of the following function is not invoked by math module?
ceil( )
floor( )
sqrt( )
mean( )
17. Which method of pickle module reads data from a binary file?
dump( )
load( )
read( )
reader( )
18. Write the output of the following: def c(x, y): if x % y : return x+5 else: return y+10 print(c(20, 5))
26
15
30
10
19. Write the output of the following: def guess(n="k", a=20, r="t"): return a, n, r t=guess("k", "t", 7) print(t)
(‘k’, ‘t’, 7)
(‘t’, ‘k’, 7)
(7, ‘t’, ‘k’)
(‘t’, 7, ‘k’)
20. Write the output of : print(sum(1,2,1))
Error
4
2
3
21. Write the output of the following: val = 20 def display (N): val = 25 if N%5 == 0: val = val + N else: val = val - N print(val, end="#") display(70) print(val)
70#20
95#20
75#20
50#20
22. Write the output of the following: def disp(m="A", t = 1): for i in range(t): print(m * 1, end="#") disp('B', 5)
B#B#B#B#B#
BBBBB
BBBBB#
#BBBBB#
23. Write the output of the following: def calc(x): r=2*x**2 return r print(calc(3))
18
8
36
9
24. Write the output of the following : def var(var, lst): lst[0] = var k = 33 a = [1, 2, 3] var(k, a) print(a)
1, 2, 3]
[33, 1, 2, 3]
[33, 1, 2]
Error
25. Which of the following module is used with binary files?
math
csv
random
pickle
26. Which of the following module is used for function max( )??
math
csv
random
No module is required
27. Write the output of the following : t=(32, 34, 33, 33.5, 41, 44, 33) print(sum(t) + t.count(33))
252.0
253.0
252.5
254
28. How many numbers will be printed by the following code: def fun(n1,n2): for x in range(n1,n2+1): if x%4==0: print(x, end=" ") fun(100,120)
5
6
7
8
29. Write the output of the following: def lst(l1): for x in l1: print(x.lower(),end="---") lst(["MCQ","PAPER"])
MCQ—PAPER—
mcq—paper—
—mcq—paper
None of the above
Submit