Explanation:
Line 1: print(...)
print() is a built-in Python function.
It is used to display the output on the screen.
Whatever is inside the parentheses () is evaluated first, and then the result is printed.
Line 2: {1, 2, 3}
{1, 2, 3} is a set.
A set is an unordered collection of unique elements.
Elements in this set are:
1
2
3
Line 3: {2, 3, 4}
This is another set.
It contains:
2
3
4
Line 4: & (Intersection Operator)
The & operator is called the intersection operator for sets.
It returns only the elements that are common to both sets.
First Set
{1, 2, 3}
Second Set
{2, 3, 4}
Common Elements
2
3
So,
{1, 2, 3} & {2, 3, 4}
becomes
{2, 3}
Line 5: print({2, 3})
The print() function displays the result:
{2, 3}
Output
{2, 3}

0 Comments:
Post a Comment