Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 1 : 1

Advertisement

Detailed Solution

सही उत्तर 1 है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

Consider the Python fragment: d = {1: 'a', True: 'b', 1.0: 'c'}; print(len(d)); What is printed? / Python कोड खंड पर विचार करें: d = {1: 'a', True: 'b', 1.0: 'c'}; print(len(d)); क्या मुद्रित होगा?

1.
1
2.
2
3.
3
4.
0

Correct Answer: 1

In Python, True == 1 == 1.0 and all three hash equally, so they collapse into a single dictionary key and len(d) is 1. / Python में True == 1 == 1.0 है और तीनों का हैश समान है, अतः वे एक ही डिक्शनरी कुंजी में सिमट जाते हैं और len(d), 1 है।

Downloaded from PrepSnap (prepsnap.in)