ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
Python MCQ Practice Questions SET 8
2
3
Sr. No.QuestionOption 1Option 2Option 3Option 4Correct Option
4
71Which method returns the number of key-value pairs in a dictionary in Python?A) size()B) count()C) length()D) len()D
5
72What 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
73Which 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
74What does the items() method return when called on a dictionary in Python?A) List of keysB) List of valuesC) List of tuples containing key-value pairsD) List of dictionariesC)
8
75Which 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
76How can you input key-value pairs for a dictionary at runtime in Python?A) Using the input() function with a loopB) Hardcoding values in the codeC) Using the read() functionD) Manually creating a text fileA
10
77What does the clear() method do when called on a dictionary in Python?A) Removes the last key-value pairB) Removes all keysC) Clears all key-value pairsD) Deletes the dictionaryC)
11
78How to create a tuple in Python?(1, 2, 3)[1, 2, 3]{1, 2, 3}{1: 2, 3}A
12
79What does the count() method in tuple return?Total number of elements in the tupleNumber of occurrences of a specified element in the tupleSum of all elements in the tupleLength of the tupleB
13
80What does the index() method in tuple return?Index of the first occurrence of a specified elementIndex of the last occurrence of a specified elementTotal number of elements in the tupleLength of the tupleA
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