Anshu created two dictionaries “D1†and “D2†in python. Later on she wants to add all the elements of D2 in D1. As a friend of Anshu, help her to write the code.
1.D1.update(D2)
2.D2.update(D1)
3.D1.append(D2)
4.D2.append(D1)
Dhriti wants to create a dictionary with “Janâ€, “Febâ€, “Mar†as key and 31, 28, 31 as values respectively. Help her to write the correct code.
1.D = {“Jan†: 31, “Feb†: 28, “Mar†: 31}
2.D = [“Janâ€:31, “Febâ€:28, “Marâ€:31]
3.D = {“Jan†; 31, “Feb†; 28, “Mar†; 31}
4.D = (“Janâ€:31, “Febâ€:28, “Marâ€:31)
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’}
1.print(D.get(3))
2.print(D.get(3))
3.Both of the above
4.None of the above
Which operator is used to check if the key is present in the dictionary or not?
1.Mathematical Operator
2.Relational Operator
3.Membership Operator
4.Logical Operator
Write the output of the following : D={1: 'Amit', 2: 'Suman', 3: 'Ravi', 4: 'Anuj'} print(tuple(D))
1.((1,â€Amitâ€, (2, “Sumanâ€), (3, “Raviâ€), (4, “Anujâ€))
2.(1, 2, 3, 4)
3.(“Amitâ€, “Sumanâ€, “Raviâ€, “Anujâ€)
4.None of the above
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])
1.. 34
2.45
3.m
4.Suman
Write the output of the following: D={1: ['Amit',23,21], 2: ['Suman',45,34], 3: 'Ravi', 4: 'Anuj'} print("Amit" in D)
1.True
2.False
3.Error
4.None of the above