Python Interview Questions on Dictionaries

python questions

Question1 : What is dictionary?

Question2 : How can we intiate a dictionary?

Question3 : How can we create a new key/value pair in dictionary?

Question4 : How to delete a key from a dictionary?

Question5 : What would be output in following scenario? I have a dictionary with name dict1={“1″:”ab”,”2″:”cd”} and now I want to know the value of key 4 i.e. dict1[‘4’]

Question6: What would be output in the following scenario? I have a dictionary with more than 100+ key-value pairs. I want to access the value of a specific key but chances are there it might not be present there.If the key not present then the program should return “no key with this name”

Question7: How to do iteration in a dictionary?

Question8: How to print both key and values of a dictionary?

Question9: How to print all keys of a dictionary?

Question10: How to print all values of a dictionary?

Question11: How can we merge 2 dictionaries?

Question12: How python’s built in dictionaries implemented?

Question13: Write a python snippet to convert dictionary keys as a list in python?

Question14: How to create a dictionary from an array?

Question15: Write a python snippet to map two lists given into a dictionary?

Question16: Can we create a dictionary from a string?

Try to solve these questions on Date time python

Try to solve these questions yourself before looking out at the answers.

Comment below if you want me to improve the post by giving your valuable suggestions below.

Be the first to comment

Leave a Reply

Your email address will not be published.


*