+ 1
Set difference Why set second - first is 8,7,9 not 7,8,9
first = {1, 2, 3, 4, 5, 6} second = {4, 5, 6, 7, 8, 9} print(first | second) print(first & second) print(first - second) print(second - first) print(first ^ second)
4 Answers
+ 5
Zahed Shaikh
This little code uses the random nature of SET to create a random number.
I am hoping that it may help you understand the nature of set
https://code.sololearn.com/c71Ipk1X1Mqq/?ref=app
+ 2
Zahed Shaikh
Sets are not ordered.
If you were to run your code multiple times, you will probably see a mixed ordered output
+ 1
So set is random number generator
+ 1
Not quite!
Set stores the values in a random manner, which means you can't use an index to call a specific value.
The code I showed puts a set of a range of numbers into a list.
The set stores the range in a random manner.
By putting it into a list, I can now call a specific index from the list