Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 2 : 2 / 2
Advertisement
Detailed Solution
सही उत्तर 2 / 2 है।
Key Points
Helpful?
Question:
What is the output of the following Python code? `s = {0, False, 0.0, 'x'}` / `print(len(s))` / निम्नलिखित Python कोड का आउटपुट क्या होगा? `s = {0, False, 0.0, 'x'}` / `print(len(s))`
1.
4 / 4
2.
2 / 2
3.
1 / 1
4.
3 / 3
Correct Answer: 2 / 2
In Python, `0`, `False` and `0.0` are equal and hash identically, so a set keeps only one of them; with `'x'` the set is `{0, 'x'}` of length 2. The trap is counting four distinct elements. / Python में `0`, `False` और `0.0` समान हैं और एक जैसा hash देते हैं, अतः set इनमें से केवल एक रखता है; `'x'` के साथ set `{0, 'x'}` बनता है जिसकी लंबाई 2 है। जाल चार अलग तत्व गिनना है।
Downloaded from PrepSnap (prepsnap.in)