66 solutions available
Question 1Assertion (A): Dictionary is a collection of key-value pairs.Reasoning (R): Each key in a dictionary maps to a corresponding value. Keys...
Question 2Assertion (A): Dictionaries are enclosed within curly braces { }.Reasoning (R): The key-value pairs are separated by commas (,).Both A and...
Question 3Assertion (A): The popitem() method can be used to delete elements from a dictionary.Reasoning (R): The popitem() method deletes the last...
Question 4Assertion (A): Keys of the dictionaries must be unique.Reasoning (R): The keys of a dictionary can be accessed using values.Both A and R...
Question 5Assertion (A): clear() method removes all elements from the dictionary.Reasoning (R): len() function cannot be used to find the length of a...
Question 6Assertion (A): Items in dictionaries are unordered.Reasoning (R): You may not get back the data in the same order in which you had entered...
Question 7Assertion (A): Consider the code given below:d={1: 'Amit', 2: 'Sumit', 5:'Kavita'} d.pop(1) print(d) The output will be:Amit #item is...
Question 1Like lists, Dictionaries are mutable which means they can be changed.
Question 2A Python dictionary is a mapping of unique keys to values. It is a collection of key-value pairs.
Question 3The association of a key and a value is called a Key-Value pair.
Question 4To create a dictionary, key-value pairs are separated by comma.
Question 5In key-value pair, each key is separated from its value by a colon(:).
Question 6keys() function returns the keys of the dictionary.
Question 7Keys of a dictionary must be unique.
Question 8To delete an element, you can either use del statement or use pop() method.
Question 9The len() function returns total number of key-value pairs in a dictionary.
Question 10Accessing a value specified by a key, which is not in a dictionary using get() function, returns None.
Question 1Which of the statement(s) is/are correct?In Python dictionary, the key-value pair is called an item.Python dictionary is a mapping of...
Question 2To create an empty dictionary, we use the statement as:d1 = {}d1 = []d1 = ()d1 == {}
Question 3In a dictionary, the elements are accessed through:keyvaluelabelNone of these
Question 4Keys of a dictionary must be:SimilarUniqueBoth (i) and (ii)All of these
Question 5To create a new dictionary with no items:Dictdict()d1={}Both 2 and 3
Question 6Which function is used to return a value for the given key?len()get()keys()None of these
Question 7Which function is used to remove all items from a particular dictionary?clear()pop()delete()rem()
Question 8What will be the output of the following Python code snippet?d1 = { "amit" :40, "jatin" :45} d2 = { "amit" :466, "jatin" :45} d1 >...
Question 9Which of the following functions will return key-value pairs of the dictionary in the form of list of tuples?key()values()items()get()
Question 10Select the correct option to get the values of marks key:Student={ "name" : "Emma", "class" :11, "sec": "a", "marks"...
Question 11Consider the given code:D1={1: 'India', 2: 'Russia', 3: 'World'} D2={'School' : 'EOIS' , 'Place ' : 'Moscow'} print(D1.update (D2) )What...
Question 1What is a key-value pair in dictionary?
Question 2What are the differences between strings and dictionary?
Question 3(a)Find errors and rewrite the same after correcting the following code:d1 = {1:10, 2.5:20, 3:30, 4:40, 5:50, 6:60, 7:70}
Question 3(b)Find errors and rewrite the same after correcting the following code:d1(9) = 90
Question 3(c)Find errors and rewrite the same after correcting the following code:del d1(2)
Question 3(d)Find errors and rewrite the same after correcting the following code:pop d1[4]
Question 3(e)Find errors and rewrite the same after correcting the following code:d1.item()
Question 3(f)Find errors and rewrite the same after correcting the following code:d1.key()
Question 3(g)Find errors and rewrite the same after correcting the following code:d1.value()
Question 3(h)Find errors and rewrite the same after correcting the following code:d1.gets(4, 80)
Question 3(i)Find errors and rewrite the same after correcting the following code:d1.len()
Question 3(j)Find errors and rewrite the same after correcting the following code:d1.clears()
Question 4(a)Suppose>>> d1 = { 1 : 'one' , 2: 'two' , 3: 'three' , 4: 'four'} >>> d2 = { 5 :'five', 6:'six' }Write the output of...
Question 4(b)Suppose>>> d1 = { 1 : 'one' , 2: 'two' , 3: 'three' , 4: 'four'} >>> d2 = { 5 :'five', 6:'six' }Write the output of...
Question 5Write a Python program to find the highest 2 values in a dictionary.Solutiond = {'a': 10, 'b': 30, 'c': 20, 'd': 50, 'e': 40} s =...
Question 6Write a Python program to input 'n' classes and names of their class teachers to store it in a dictionary and display the same. Also,...
Question 7Write a program to store students' names and their percentage in a dictionary, and delete a particular student name from the dictionary....
Question 8Write a Python program to input names of 'n' customers and their details like items bought, cost and phone number, store it in a dictionary...
Question 9What type of objects can be used as keys in dictionaries?
Question 10How will you check for a value inside a dictionary using in operator?
Question 11How is clear() function different from del statement?
Question 12The following code is giving some error. Find out the error and write the corrected code.d1 = { "a" : 1, 1 : "a", [1, "a"] : "two"}
Question 13What will be the output of the following code?d1 = {5: [6,7,8], "a": (1,2,3)} print (d1.keys () ) print (d1.values () )
Question 14(a)Write the output of the following code:d = { (1,2):1, (2,3):21 } print (d[1,2] )
Question 14(b)Write the output of the following code:d = {'a':1, 'b':2, 'c':3} print (d['a'])
Question 15Write a program to input your friends' names and their phone numbers and store them in a dictionary as the key-value pair. Perform the...
Question 16Consider the following dictionary Prod_Price.Prod_Price = {'LCD' : 25000, 'Laptop' : 35000, 'Home...
Question 17Write a program that prompts the user for product names and prices, and store these key-value pairs in a dictionary where names are the...
Question 18Write a Python program that accepts a value and checks whether the inputted value is part of the given dictionary or not. If it is...
Question 1An element in a dictionary is a combination of key-value pairs.
Question 2Internally, dictionaries are indexed on the basis of values.
Question 3We can repeat a key in dictionary.
Question 4In dictionary, two unique keys can have the same values.
Question 5clear() is used to delete a dictionary.
Question 6The key of a dictionary is a mutable data type.
Question 7List can be used as keys in a dictionary.
Question 8Updating an element in a dictionary at runtime is possible.
Question 9We can create immutable dictionaries in Python.