Python/Dictionary Python MCQ set 2 Sample Test,Sample questions

1.D1.update(D2)

2.D2.update(D1)

3.D1.append(D2)

4.D2.append(D1)

Question: `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)

Question: `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

Question: ```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

Question: ```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

1.. 34

2.45

3.m

4.Suman

Question: ```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

More MCQS

R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!