| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Python MCQ Practice Questions SET 11 | |||||||||||||||||||||||||
2 | ||||||||||||||||||||||||||
3 | Sr. No. | Question | Option 1 | Option 2 | Option 3 | Option 4 | Correct Option | |||||||||||||||||||
4 | 101 | What is the purpose of a loop in programming? | To execute a block of code repeatedly | To terminate the program | To perform arithmetic operations | To print a single value | A | |||||||||||||||||||
5 | 102 | Which type of loop in Python is typically used to iterate over elements in a sequence? | for | while | do-while | repeat-until | A | |||||||||||||||||||
6 | 103 | What 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 | 104 | Which method can be used with a for loop to specify a particular range of iterations? | range() | count() | length() | loop() | A | |||||||||||||||||||
8 | 105 | What does the while keyword represent in Python? | A loop that executes until a condition becomes false | A loop that executes a fixed number of times | A loop that iterates over a sequence | A loop that increments a counter | A | |||||||||||||||||||
9 | 106 | Which loop is suitable when the number of iterations is not known beforehand? | while | for | do-while | repeat-until | A | |||||||||||||||||||
10 | 107 | What 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 false | The for loop executes a fixed number of times, while the while loop iterates over a sequence | The for loop requires a counter variable, while the while loop does not | The for loop increments a counter, while the while loop decrements a counter | A | |||||||||||||||||||
11 | 108 | set1={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 above | A | |||||||||||||||||||
12 | 109 | What is the purpose of a function in Python? | To perform a specific task | To print a single value | To terminate the program | To iterate over a sequence | A | |||||||||||||||||||
13 | 110 | Which keyword is used to define a function in Python? | def | func | define | function | A | |||||||||||||||||||
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 | ||||||||||||||||||||||||||