29 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 3Assertion (A): The popitem() method can be used to delete elements from a dictionary.Reasoning (R): The popitem() method deletes the last...
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 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 2What are the differences between strings and dictionary?
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(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(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...