What will be the output of the following Python code? [code]s1={1, 2, 3} s2={4, 5, 6} s1.isdisjoint(s2) s2.isdisjoint(s1)[/code]

What will be the output of the following Python code?
Code:
s1={1, 2, 3}
s2={4, 5, 6}
s1.isdisjoint(s2)
s2.isdisjoint(s1)
A.
True
False
B.
False
True
C.
True
True
D.
False
False
 
Answer: c
Explanation: The function isdisjoint returns true the two sets in question are disjoint, that is if they do not have even a single element in common. The two sets s1 and s2 do not have any elements in common, hence true is returned in both the cases.
 

Tìm kiếm

Back
Top