Untitled
10 Questions
9 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

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

    ___________function returns a list of values in the dictionary.

    <p>values()</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</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</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</p> Signup and view all the answers

    to delete the dictionary from the memory we use _______ function

    <p>del()</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</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])</p> Signup and view all the answers

    More Like This

    Use Quizgecko on...
    Browser
    Browser