ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
Python MCQ Practice Questions SET 11
2
3
Sr. No.QuestionOption 1Option 2Option 3Option 4Correct Option
4
101What is the purpose of a loop in programming?To execute a block of code repeatedlyTo terminate the programTo perform arithmetic operationsTo print a single valueA
5
102Which type of loop in Python is typically used to iterate over elements in a sequence?forwhiledo-whilerepeat-untilA
6
103What is the syntax for a for loop in Python?for variable in sequence:while (test_condition):for (variable = start; variable < end; variable++)for (sequence) { }A
7
104Which method can be used with a for loop to specify a particular range of iterations?range()count()length()loop()A
8
105What does the while keyword represent in Python?A loop that executes until a condition becomes falseA loop that executes a fixed number of timesA loop that iterates over a sequenceA loop that increments a counterA
9
106Which loop is suitable when the number of iterations is not known beforehand?whilefordo-whilerepeat-untilA
10
107What is the primary difference between the for and while loops in Python?The for loop iterates over a sequence, while the while loop executes until a condition is falseThe for loop executes a fixed number of times, while the while loop iterates over a sequenceThe for loop requires a counter variable, while the while loop does notThe for loop increments a counter, while the while loop decrements a counterA
11
108set1={1,2,3,4,5,6,7,8,9,17}
set2={1,2,3,4,5,6}
set3=set2.difference(set1)
print("The union of set1 and set2 is:",set3) what will the output of given code
The union of set1 and set2 is: set()The union of set1 and set2 is: {8, 9, 17, 7}The union of set1 and set2 is: {1,2,3,4,5,6,7,8,9,17}None of the aboveA
12
109What is the purpose of a function in Python?To perform a specific taskTo print a single valueTo terminate the programTo iterate over a sequenceA
13
110Which keyword is used to define a function in Python?deffuncdefinefunctionA
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