Dictionaries Flashcards

(5 cards)

1
Q

Indexing operation — retrieves the value associated with key

A

my_dict[key]

jose_grade = my_dict[“Jose”]

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

my_dict[key] = value

A

Adds an entry if the entry does not exist, else modifies the existing entry.

my_dict[“Jose”] = “B+”

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

del my_dict[key]

A

Deletes the key from a dict.

del my_dict[“Jose”]

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

key in my_dict

A

Tests for existence of key in my_dict.

if “Jose” in my_dict: # ….

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