w6 Flashcards

(21 cards)

1
Q

how to see if something is in a set

A

“in” operator

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

farm_animals.add(cow)

A

inserts cow into set

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

farm_animals.remove(cow)

A

removes cow from set

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

farm_animals.clear()

A

clear method empties set

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

print(pets | farm_animals)

A

creates a new set with both obj and arg

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

print(pets & farm_animals)

A

creates a new set containing items common to both

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

print(pets - farm_animals)

A

creates a new set containing items common to obj but not in arg

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

print(pets ^ farm_animals)

A

symmetric diff - creates a set with items in one set or the other but not in both

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

my_pets<=pets

A

is subset - are “my_pets” set in “pets” set

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

pets>=my_pets

A

is superset - does pets contain all of my pets

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

2 components of dictionaries

A

key and value pairs

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

3 characteristics of keys

A

unordered, any key can appear only once, are immutable

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

what does {} by itself mean

A

empty dictionary

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

how to clear dictionary

A

d.clear()

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

fruit_counts.get(‘apple’)

A

returns value associated with apple

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

fruit_counts.pop(‘apple’)

A

deletes key and its value

17
Q

fruit_counts[‘mango’] = 42

A

adding the key mango with a value of 42

18
Q

fruit_counts.keys()

A

returns a list-like object of dictionaries keys

19
Q

fruit_counts.items()

A

returns a list-like object of dictionaries keys and values

20
Q

fruit_counts.values()

A

returns a list-like object of dictionaries values

21
Q

fruit_counts.update()

A

adds a set of key/value pairs or even another dictionary