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
It gives True if the key 'RNo' is in D1, and False if it is not. 'RNo' in D1
Write a Python expression to check if any key in D1 has a value 12.
12 in D1.values()
D1.values() gives all the values of D1, and in checks if 12 is one of them. 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)
D1.setdefault('RNo', 12)
Write a single statement to delete all the elements from D1.
D1.clear()
D1.clear()