CBSE Class 11 Computer Science
Question 58 of 88
Tuples and Dictionary — Question 23
Back to all questions{1: 'one', 2: 'two', 4: 'four'}
'four'
{1: 'one', 2: 'two'}
{1: 'one', 2: 'two', 8: ' eight'}
{}
del d1[3]: Removes the key 3 and its corresponding value 'three' fromd1. After deletion,d1contains {1: 'one', 2: 'two', 4: 'four'}.d1.pop(4): Removes the key 4 and its corresponding value 'four' fromd1. After popping,d1is {1: 'one', 2: 'two'}.d1[8] = 'eight': Adds a new key-value pair 8: 'eight' tod1. Nowd1becomes {1: 'one', 2: 'two', 8: 'eight'}.d1.clear(): Clears all key-value pairs fromd1, resulting in an empty dictionary{}.