Dictionary Preeti Arora Class 11 IP Solution || Dictionary Class 11 Solution || Dictionary Class 11 IP Solution || Dictionary Information Practices Solution || Preeti Arora Dictionary Solution || Dictionary Class 11 IP || Dictionary Solution


Note :- Please Click on Question to get Solution of that question !!


Q1. What is a key-value pair in dictionary?


Q2. What are the differences between strings and dictionary?


Q3. Find errors and rewrite the same after correcting the following code:
(a) d1 = {1:10, 2.5:20, 3:30, 4:40, 5:50, 6:60, 7,70}
(b) d1 (9)=90
(c) del d1 (2)
(d) pop d1 [4]
(e) d1.item ()
(f) d1.key()
(g) d1.value ()
(h) d1.gets (4,80)
(i) d1.len ()
(j) d1.clears ()




Q4. Suppose
>>>d1 = {1: 'one', 2: 'two', 3: 'three', 4: 'four'}
>>>d2 = {5: 'five', 6: 'six'}
Write the output of the following code:
(a)
>>>d1.items ()
>>>d1.keys ()
>>>d1.values ()
>>>d1.update (d2)
>>>len (d1)
(b)
>>>del d1[3]
>>>print (d1)
>>>d1.pop (4)
>>>print (d1)
>>>d1 [8] = 'eight'
>>>print (d1)
>>>d1.clear ()
>>>print (d1)




Q5. Write a Python program to input 'n' classes and names of their class teachers to store it in a dictionary and display the same. Also accept a particular class from the user and display the name of the class teacher of that class.



Q6. Write a program store student name and their percentage in a dictionary, delete a particular student name from the dictionary. Also display dictionary after deletion.



Q7. Write a Python program to input names of 'n' customers and their details like items bought, cost and phone number, store it in a dictionary and display all the details in a tabular form.



Q8. What type of objects can be used as keys in dictionaries?



Q9. Can you check from a value inside a dictionary using in operator? How will you check for a value inside a dictionary using in operator?



Q10. How is clear () function different from del () statement?



Q11. The following code is giving some error. Find out the error and write the corrected code.
d1 = {“a":1, 1:"a", [1, "a"]:"two"}




Q12. What will be the output of the following code:

d1 = {5: [6, 7, 8], "a": (1, 2, 3)}
print (d1.keys ())
print (d1.values())




Q13. Predict the output:
(a)
d = {(1, 2):1, (2, 3):2}
print (d[1, 2])
(b)
d = {'a': 1, 'b':2, 'c':3}
print (d['a', 'b'])




Q14. Write a program that asks the user to enter product names and prices. Store all of these in a dictionary whose keys are the product names and whose values are the prices. When the user is done entering products and prices, allow them to repeatedly enter a product name and print the corresponding price or message if the product is not in the dictionary.



Q15. Write a Python program that accepts a value and checks whether the inputted value is part of given dictionary or not. If it is present, check for the frequency of its occurrence and print the corresponding key otherwise print an error message.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post