I had seen this test question on Pluralsight:
Given these sets:
x = {'a', 'b', 'c', 'd'}
y = {'c', 'e', 'f'}
z = {'a', 'g', 'h', 'i'}
What is the value of x | y ^ z
?
The expected answer is:
{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'}
Combines the sets (automatically discarding duplicates), and orders them from lowest to greatest.
My questions are:
- What is this expression called?
- Why do I get 3 different results from 3 different Python versions?
Result on Python 3.7.5 on Ubuntu 18.04:
{'c', 'h', 'f', 'd', 'b', 'i', 'g', 'a', 'e'}
Result on Python 2.17.17rc1 on Ubuntu 18.04:
set(['a', 'c', 'b', 'e', 'd', 'g', 'f', 'i', 'h'])
Result on Python 3.7.2 on Windows 10:
{'a', 'd', 'h', 'f', 'b', 'g', 'e', 'c', 'i'}
Here is a repl of the same code I'm using for this: https://repl.it/repls/RudeMoralWorkplace
I'd like to understand what happens behind the scenes with these expressions so I can debunk why I get different results.