ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
Python MCQ Practice Questions SET 14
2
3
Sr. No.QuestionOption 1Option 2Option 3Option 4Correct Option
4
131for i in range(7):
print(I,End=" ") What will be output of given code
0
1
2
3
4
5
6
123456End' is an invalid keyword 0 1 2 3 4 5 6 C
5
132while i<=6:
if i%2==0:
print(i)
i+=1 What will be the output of given code
60 2 4 6 0
2
4
6
0
2
4
5
A
6
133f1=0
f2=1
i=1
while i<8:
f3=f1+f2
f1=f2
f2=f3
print(f3)
i+=1
What will be the output of given code
1
2
3
5
8
13
21
34
1
2
3
5
8
13
21
0
1
2
3
5
8
13
21
0
1
2
3
5
8
13
21
34
B
7
134dict1={1:10,2:20,3:30,4:40,5:50,6:60,7:13,8:"Hello"}
for key,value in dict1.items():
print(key,value) what will be the output of given code
1 10
2 20
3 30
4 40
5 50
6 60
7 13
8 Hello
1
2
3
4
5
6
7
8
10
20
30
40
50
60
13
Hello
Error in codeA
8
135
What is the purpose of a lambda function in Python?
To define a function with a single expressionTo create anonymous functions
To apply a function to a sequence of elements
To perform arithmetic operationsb
9
136my_set={"Python","DBMS","C","C++"}
my_dict=dict(zip(my_set,range(len(my_set))))
print(my_dict) what will be the output of given code
{'Python': 1, 'C': 2, 'DBMS': 3, 'C++': 4}{'Python': 0, 'C': 1, 'DBMS': 2, 'C++': 3}{'Python': 10, 'C': 1, 'DBMS': 2, 'C++': 3}None of aboveB
10
137my_tuple=(1,22,33,4,5,6,0)
sorted_tuple=sorted(my_tuple,reverse=0)
print(sorted_tuple) what will be the output of given code
[0, 1, 4, 5, 6, 22, 33][33, 22, 6, 5, 4, 1, 0](1, 22, 33, 4, 5, 6, 0)None of aboveA
11
138Which built-in function in Python returns the ASCII value of a character?chr()ord()encode()b
12
139What does the any() function in Python return?True if all elements in an iterable are trueTrue if any element in an iterable is trueTrue if all elements in an iterable are falseTrue if any element in an iterable is falseb
13
140What is the purpose of the eval() function in Python?To evaluate an expressionTo execute a Python scriptTo convert a string to a floating-point numberTo execute a system commanda
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100