Ques 1 Dictionary
Dictionary is a.......
Ques 2 Dictionary
What is the output of the following Python Code?
di={1:1,2:2,4:4} print(di)
Ques 3 Dictionary
What is the output of the following Python Code?
di={1:1,2:4,4:16} print(di[2])
The given Python code creates a dictionary di with the key-value pairs {1:1, 2:4, 4:16}. It then prints the value corresponding with the key 2.
The value associated with the key 2 in the dictionary is 4.
So the correct answer is b) 4
Ques 4 Dictionary
What is the output of the following Python Code?
d1={1:1,2:4,4:16} d2={-1:1,-2:4,-3:6} if d1>d2: print("YES") else: print("No")
The given Python code will gives an error because dictionary comparison using the > operator is not supported in Python. Comparing dictionaries directly using comparison operators like >, <, >=, and <= is not allowed, and it will raise a TypeError.
So the correct answer is c)Error