Sets Flashcards

1
Q

How to create an empty set?

A

set()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What will {} create?

A

An empty dictionary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to check a value is in a set?

A

x in set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to get unique characters in a string?

A

set(‘adsbdash’)

will return a set of unique chars

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

a -b

A

letters in a but not in b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

a | b

A

letters in a or b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

a ^ b

A

a or b but not in both

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

a & b

A

a and b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

set comprehension

A

{x for x ‘abdgcj’ if not in ‘jih’ }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly