Untitled

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

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

  • 2
  • 3 (correct)
  • 5
  • 6

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

  • ['Ajay','prem','Rehan'] (correct)
  • ['Ajay','prem']
  • ['Ajay':50,'prem':55,'Rehan':45]
  • error

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

False (B)

___________function returns a list of values in the dictionary.

<p>values() (B)</p> Signup and view all the answers

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

<p>4 (D)</p> Signup and view all the answers

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

<p>by assigning a value to a new key (D)</p> Signup and view all the answers

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

<p>0 (B)</p> Signup and view all the answers

to delete the dictionary from the memory we use _______ function

<p>del() (B)</p> Signup and view all the answers

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

<p>by using the pop() method (C)</p> Signup and view all the answers

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

<p>dict_values([3,2,1]) (A)</p> Signup and view all the answers

Flashcards are hidden until you start studying

Use Quizgecko on...
Browser
Browser