Assuming that D1 is a dictionary in Python,
Write a Python expression to check if the key, 'RNo' is present in D1.
'RNo' in D1
'RNo' in D1
Write a Python expression to check if any key in D1 has a value 12.
12 in D1.values()
The result is True when some key holds the value 12, and False otherwise. 12 in D1.values()
Write a single statement using a BUILT_IN function to add the key : value pair 'RNo' : 12, if the key 'RNo' is not present in D1. However, if the key 'RNo' is present, the function should return its value.
D1.setdefault('RNo', 12)
Test on D1 = {'Name': 'A', 'Age': 12}: the call returns 12 and D1 now has the pair 'RNo' : 12. D1.setdefault('RNo', 12)
Write a single statement to delete all the elements from D1.
D1.clear()
On D1 = {'Name': 'A', 'Age': 12}, print(D1) after the call shows {}. D1.clear()