Dictionary Methods

 0    12 flashcards    sir
download mp3 print play test yourself
 
Question Answer
Removes all the elements from the dictionary
start learning
. clear()
Returns a copy of the dictionary.
start learning
. copy()
Returns a dictionary with the specified keys and values
start learning
dict. fromkeys(keys, value)
Returns the value of the specified key
start learning
. get(key)
Returns a list containing the dictionary's keys
start learning
. keys()
Returns a list containing the a tuple for each key value pair
start learning
. items()
Removes the element with the specified key
start learning
. pop(key)
Removes the last inserted key-value pair
start learning
. popitem(keyname, defaultvalue)
Returns the value of the specified key. If the key does not exist: insert the key, with the specified value
start learning
. setdefault(keyname, value)
Updates the dictionary with the specified key-value pairs
start learning
. update(iterable)
Returns a list of all the values in the dictionary
start learning
. values()
Checks whether a dictionary possesses the give key/index.
start learning
. has_key()

You must sign in to write a comment