Untitled

SmoothestChalcedony avatar
SmoothestChalcedony
·
·
Download

Start Quiz

Study Flashcards

10 Questions

what will be the output of the following code? d={'Ajay':50,'prem':55,'Rehan':45} print(len(d))

3

what will be the output of the following code? d={'Ajay':50,'prem':55,'Rehan':45} print(list(d.keys()))

['Ajay','prem','Rehan']

items are accessed by their position in a dictionary and all the keys in a dictionary must be of the same type.

False

___________function returns a list of values in the dictionary.

values()

what will be the output of the following code? a={} a[2]=5 a[1]=[1,2,3,4] print(a[1][3])

4

how a new key-value pair is added to a dictionary in python?

by assigning a value to a new key

what will be the output of the following code? my_dict={"apple":3,"mango":2,"orange":1} print(my_dict.get("grape",0))

0

to delete the dictionary from the memory we use _______ function

del()

how do you remove a key-value pair from a dictionary in python?

by using the pop() method

what will be the output of the following code? my_dict={"apple":3,"mango":2,"orange":1} print(my_dict.values())

dict_values([3,2,1])

Test your knowledge on Python dictionary operations with this quiz. It covers topics such as getting the length of a dictionary, accessing keys, adding key-value pairs, and more.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Python Program for Word Analysis
5 questions

Python Program for Word Analysis

SelfDeterminationWashington avatar
SelfDeterminationWashington
Dictionary Methods Quiz
10 questions
Use Quizgecko on...
Browser
Browser