Explanation:
Step 1: Create two sets.
a = {2, 4, 6}b = {4, 6, 8}
- Set a contains {2, 4, 6}.
- Set b contains {4, 6, 8}.
Step 2: Understand a ^ b.
The ^ operator performs symmetric difference. It returns elements that are present in either set, but not in both.
a ^ b
Output:
{2, 8}
Length = 2
Step 3: Understand a & b.
The & operator performs intersection. It returns common elements from both sets.
a & b
Output:
{4, 6}
Length = 2
Step 4: Calculate the final expression.
len(a ^ b) + len(a & b)
= 2 + 2
3. Final Output
Correct Answer: 4
.png)

0 Comments:
Post a Comment