+ 2
can someone explain this code? thanksđ
a = {"a", "b", "c", "d"} b = {"b", "d", "e"} c = {"e", "b", "a"} print((b^c) - a)
6 Answers
+ 4
These are sets
B intersection C i.e elements that are present in either B or C but not in both
In this case, Result would be
d,a
(B intersection C) - A
i.e remove all elements that are present in A from (B intersection C)
In this case,
d and a are both present in A so both are removed and we are left with a null set
edit: ^ is called **symmetric difference** not intersection
+ 3
(b^c)={'a','d'}
{'a','d'}-a=set()
https://pythonworld.ru/tipy-dannyx-v-JUMP_LINK__&&__python__&&__JUMP_LINK/mnozhestva-set-i-frozenset.html
+ 3
When elements are in a curly bracket with no key-value pair, then it's a set. ^ is a set operation (intersection)
+ 3
The caret ^ means intersection. and the variables a, b, and c are sets.
Sets are like lists but unordered and set elements are immutable and each Element is unique.
So the above means all elements common to both sets b and c but not in a.
+ 2
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2464/
a, b, and c here are sets.
(b^c) is a set that contains elements that are in b and c but not both.
((b^c) - a) is a set containing elements in (b^c) that are not in a.
+ 2
thank u all very muchđș