Python Dictionary Methods Flashcards
1
Q
clear()
A
Removes all the elements from the dictionary
2
Q
copy()
A
Returns a copy of the dictionary
3
Q
fromkeys()
A
Returns a dictionary with the specified keys and value
4
Q
get()
A
Returns the value of the specified key
5
Q
items()
A
Returns a list containing a tuple for each key value pair
6
Q
keys()
A
Returns a list containing the dictionary’s keys
7
Q
pop()
A
Removes the element with the specified key
8
Q
popitem()
A
Removes the last inserted key-value pair
9
Q
setdefault()
A
Returns the value of the specified key. If the key does not exist: insert the key, with the specified value
10
Q
update()
A
Updates the dictionary with the specified key-value pairs
11
Q
values()
A
Returns a list of all the values in the dictionary