57. Sets Flashcards

1
Q

what is a set

A

unordered collections of objects

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

what does a set do

A

does not print two of the same value when written is my_set =[1,2,3,4,5}
print(my_set)

printsonly 1,2,3,4,5

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

how will put a list into a set to remove duplicates?

A

print(set( my_list) )

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

how do you check something in a set like
my_set ={1,2,3,4,5,5}
what does len do in this case>

A

do
print(1 in my_set)

prints true

will put lenghth, but in a way that not include dupl.

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

.difference do when you have two sets?

A
  • so, you write
    print(first set.differnce9second set))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what does .discard() do to a set

A

takes away the # in the ()

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

what does .difference_update () do

A

tells you the differene+ the update update it

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

.intersection()

A

prints what both together have in common

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

.iddisjoint()

A

-nothing in common

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

.union

A

unites sets and takes away duplicates when you have two sets

as print(my_set | your_set)

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

.issubset
what does (my_set.issubset(your_set ))

A

inside of the circle of the other, because the other one is smaller, and in it

example

set = 2,3
2set = 2345

not accurate, but the idea is there

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