Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Question 21:Find the output of the following program:test = {1:'A', 2:'B', 3:'C'}del test[1]test[1] = 'D'del test[2]print(len(test))(A) Error(B) 0(C) 1(D) 2

Answer»
2.

Question 13:Find the output of the following program:dictionary1 = {'GFG' : 1,'Google' : 2,'GFG' : 3}print(dictionary1['GFG']);(A) Compilation error due to duplicate keys(B) Runtime time error due to duplicate keys(C) 3(D) 1

Answer»
3.

Question 19:Find the output of the following program:dictionary ={1:"geek", 2:"for", 3:"geeks"}del dictionary(A) del deletes the entire dictionary(B) del doesn’t exist for the dictionary(C) del deletes the keys in the dictionary(D) del deletes the values in the dictionary

Answer»
4.

Question 20:Find the output of the following program:a = {}a[1] = 1a['1'] = 2a[1]= a[1]+1count = 0for i in a:count += a[i]print(count)(A) 2(B) 4(C) 1(D) Error

Answer»
5.

Question 15:Find the output of the following program:temp = {'GFG' : 1,'Facebook' : 2,'Google' : 3}for (key, values) in temp.items():print(key, values, end = " ")(A) Google 3 GFG 1 Facebook 2(B) Facebook 2 GFG 1 Google 3(C) Facebook 2 Google 3 GFG 1(D) Any of the above

Answer»
6.

Question 18:Find the output of the following program:dictionary = {"geek":10, "for":45, "geeks": 90}print("geek" in dictionary)(A) 10(B) False(C) True(D) Error

Answer»
7.

Question 17:Find the output of the following program:d1 = {"john":40, "peter":45}d2 = {"john":466, "peter":45}print (d1 > d2)(A) True(B) False(C) Compilation Error(D) TypeError

Answer»
8.

Question 22:Find the output of the following program:a ={}a['a']= 1a['b']=[2, 3, 4]print(a)(A) {‘b’: [2], ‘a’: 1}(B) {‘a’: 1, ‘b’: [2, 3, 4]}(C) {‘b’: [2], ‘a’: [3]}(D) Error

Answer»
9.

Question 16:Find the output of the following program:numberGames = {}numberGames[(1,2,4)] = 8numberGames[(4,2,1)] = 10numberGames[(1,2)] = 12sum = 0for k in numberGames:sum += numberGames[k]print (len(numberGames) + sum)(A) 33(B) 12(C) 10(D) 8

Answer»
10.

Question 14:Find the output of the following program:temp = dict()temp['key1'] = {'key1' : 44, 'key2' : 566}temp['key2'] = [1, 2, 3, 4]for (key, values) in temp.items():print(values, end = "")(A) Compilation error(B) {‘key1’: 44, ‘key2’: 566}[1, 2, 3, 4](C) Runtime error(D) None of the above

Answer»
11.

Question 10:Find the output of the following program:Which of these about a dictionary is false?(A) The values of a dictionary can be accessed using keys(B) The keys of a dictionary can be accessed using values(C) Dictionaries may or may not be ordered(D) None of the above

Answer»
12.

Question 9:Find the output of the following program:a = {'geeks' : 1, 'gfg' : 2}b = {'geeks' : 2, 'gfg' : 1}print (a == b)(A) True(B) False(C) Error(D) None

Answer»
13.

Question 23:Find the output of the following program:dictionary = {}dictionary[1] = 1dictionary['1'] = 2dictionary[1] += 1sum = 0for k in dictionary:sum += dictionary[k]print (sum)(A) 4(B) 3(C) 2(D) 1

Answer»
14.

Question 8:Find the output of the following program:dict ={}print (all(dict))(A) { }(B) False(C) True(D) An exception is thrown

Answer»
15.

Question 11:Find the output of the following program:dictionary = {'GFG' : 'geeksforgeeks.org','google' : 'google.com','facebook' : 'facebook.com'}del dictionary['google'];for key, values in dictionary.items():print(key, end=" ")dictionary.clear();for key, values in dictionary.items():print(key)del dictionary;for key, values in dictionary.items():print(key)(A) Both B and D(B) GFG facebook(C) facebook GFG(D) NameError: name ‘dictionary’ is not defined

Answer»
16.

Question 24:Find the output of the following program:dictionary = {1:'1', 2:'2', 3:'3'}del dictionary[1]dictionary[1] = '10'del dictionary[2]print (len(dictionary) )(A) 1(B) 2(C) 3(D) 4

Answer»
17.

Question 12:Find the output of the following program:dictionary1 = {'Google' : 1,'Facebook' : 2,'Microsoft' : 3}dictionary2 = {'GFG' : 1,'Microsoft' : 2,'Youtube' : 3}dictionary1.update(dictionary2);for key, values in dictionary1.items():print(key, values , end=" ")(A) Google 1 Facebook 2 Microsoft 2 GFG 1 Youtube 3(B) Runtime error(C) Compilation error(D) None of these

Answer»
18.

Question 7:Find the output of the following program:a ={}a.fromkeys(['a', 'b', 'c', 'd'], 98)print (a)(A) Syntax error(B) {‘a’:98, ‘b’:98, ‘c’:98, ‘d’:98}(C) {‘a’:None, ‘b’:None, ‘c’:None.’d’:None}(D) { }

Answer»
19.

Question 25:Find the output of the following program:counter = {}def addToCounter(country):if country in counter:counter[country] += 1else:counter[country] = 1addToCounter('China')addToCounter('Japan')addToCounter('china')print (len(counter))(A) 0(B) 1(C) 2(D) 3

Answer»