Dictionary in Python Quiz #6

Share with others

Welcome to your Dictionary in Python Quiz #6

Q51. Write the output of the following:

A = {"A" : "Apple", "B" : "Ball", "C" : "Cat"}
print(A.pop("C"))

Q52. Aman wants to convert the sequence given below to dictionary. Which of the following function will help him to convert?

((1,"Amit"),(2,"Suman"),(3,"Ravi"))

Q53. Write the output of the following:

D={1: 'Amit', 2: 'Suman', 3: 'Ravi', 4: 'Anuj'}
print(max(D.values()))

Q54. Write the output of the following:

D={1: 'Amit', 2: 'Suman', 3: 'Ravi', 4: 'Anuj'}
print(D.get(3))

Q55. Which of the statement will delete third item (3: 'Ravi') from dictionary given below:

D={1: 'Amit', 2: 'Suman', 3: 'Ravi', 4: 'Anuj'}

Q56. Write the output of the following :

D={1: 'Amit', 2: 'Suman', 3: 'Ravi', 4: 'Anuj'}
print(tuple(D))

Q57. Parth wants to display the value corresponding to the key "3" in dictionary given below. As a friend of Parth, help him to find the correct code.

D={1: 'Amit', 2: 'Suman', 3: 'Ravi', 4: 'Anuj'}
 

Q58. Write the output of the following:

D={1: ['Amit',23,21], 2: ['Suman',45,34], 3: 'Ravi', 4: 'Anuj'}
m = D.get(2)
print(m[2])

Q59. Which operator is used to check if the key is present in the dictionary or not?

Q60. Write the output of the following:

D={1: ['Amit',23,21], 2: ['Suman',45,34], 3: 'Ravi', 4: 'Anuj'}
print("Amit" in D)


Share with others

Leave a Reply

error: Content is protected !!