Quiz on Dictionary in Python
Q.1. In a dictionary, the keys are mutable but values are immutable
Q.2. Are orders retained in a dictionary?
Q.3. Output of following code
d1 = {"k1":5, "k2":6}
d2 = {"k2":6, "k1":5}
print(d1 == d2)
Q.4. Which of the following is Incorrect way of creating a dictionary
Q.5. What is the output of following program?
d = {1:1, 2:4, 3:9, 4:16, 5:25}
print(d.keys())
Q.6. Do all the keys in a dictionary must have same data type?
Q.7. What is the output of following program?
d = {1:1, 2:4, 3:9, 4:16, 5:25}
d.pop(2)
print(d)
Q.8. What is the output of following program?
d = {1:'apple',2:'mango',3:'banana',2:'pear'}
print(d)
Q.9. What is the output of the following code snippet?
d = {[1,2]:'a',3:'b',4:'c'}
print(d)
Q.10. What is the output of the following code snippet?
d = {2:'a',3:'b',4:'c'}
d[1] = 'd'
print(d)
Q.11. What is the output of the following code snippet?
d = {1:1, 2:4, 3:9}
for key,val in d.items():
print(key,val, end=" ")
Q.12. What is the output of the following code snippet?
d = {1: 'a', 2: 'b', 3: {'4': 'c', '5': 'd', '6': 'e'}}
print(d)
Q.13. What is the output of the following code snippet?
d = {1:'apple',2:'mango',3:'banana',4:'pear'}
print(d[2])
Q.14. What is the output of the following code snippet?
d = {1:1, 2:4, 3:9, 4:16, 5:25}
d.popitem()
d.popitem()
print(d)
Q.15. Which of these about a dictionary is NOT true?
Instructions:-
- This Quiz is based on Dictionary in Python
- Each correct answer will carry 2 points
- Once an option is selected you cannot select any other, So choose wisely
- Do not refresh the page as it will reset the quiz
- Once the time is up the quiz will automatically get submitted with no of Question responded
- Your total score alongwith your name will be shown after submission of the Quiz
- Wish you ALL THE BEST 👍👍
START
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP