| 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 8 | |||||||||||||||||||||||||
2 | ||||||||||||||||||||||||||
3 | Sr. No. | Question | Option 1 | Option 2 | Option 3 | Option 4 | Correct Option | |||||||||||||||||||
4 | 71 | Which method returns the number of key-value pairs in a dictionary in Python? | A) size() | B) count() | C) length() | D) len() | D | |||||||||||||||||||
5 | 72 | What method is used to remove a specified key-value pair from a dictionary in Python? | A) remove() | B) discard() | C) pop() | D) delete() | C) | |||||||||||||||||||
6 | 73 | Which loop in Python is commonly used to iterate over the keys of a dictionary? | A) for key in range(len(dict)): | B) for key in dict.values(): | C) for key in dict: | D) for key in dict.items(): | C) | |||||||||||||||||||
7 | 74 | What does the items() method return when called on a dictionary in Python? | A) List of keys | B) List of values | C) List of tuples containing key-value pairs | D) List of dictionaries | C) | |||||||||||||||||||
8 | 75 | Which method in Python dictionaries is used to update the key-value pairs from another dictionary? | A) update() | B) merge() | C) append() | D) add() | A | |||||||||||||||||||
9 | 76 | How can you input key-value pairs for a dictionary at runtime in Python? | A) Using the input() function with a loop | B) Hardcoding values in the code | C) Using the read() function | D) Manually creating a text file | A | |||||||||||||||||||
10 | 77 | What does the clear() method do when called on a dictionary in Python? | A) Removes the last key-value pair | B) Removes all keys | C) Clears all key-value pairs | D) Deletes the dictionary | C) | |||||||||||||||||||
11 | 78 | How to create a tuple in Python? | (1, 2, 3) | [1, 2, 3] | {1, 2, 3} | {1: 2, 3} | A | |||||||||||||||||||
12 | 79 | What does the count() method in tuple return? | Total number of elements in the tuple | Number of occurrences of a specified element in the tuple | Sum of all elements in the tuple | Length of the tuple | B | |||||||||||||||||||
13 | 80 | What does the index() method in tuple return? | Index of the first occurrence of a specified element | Index of the last occurrence of a specified element | Total number of elements in the tuple | Length of the tuple | 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 | ||||||||||||||||||||||||||