Dictionaries Flashcards

1
Q

What can be keys in python dictionaries

A

number, string, tuples (if they are strictly one data type)

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

How to get a list of all the keys in a dictionary?

A

list(d)

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

deleting a key

A

del d[key]

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

checking if a key exists

A

key in d

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

adding a key pair value

A

d[key] = value

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