Sets Flashcards
1
Q
How to create an empty set?
A
set()
2
Q
What will {} create?
A
An empty dictionary
3
Q
How to check a value is in a set?
A
x in set
4
Q
How to get unique characters in a string?
A
set(‘adsbdash’)
will return a set of unique chars
5
Q
a -b
A
letters in a but not in b
6
Q
a | b
A
letters in a or b
7
Q
a ^ b
A
a or b but not in both
8
Q
a & b
A
a and b
9
Q
set comprehension
A
{x for x ‘abdgcj’ if not in ‘jih’ }