1. dict.
clear()
Removes all items from the dictionary.
d = {'a': 1, 'b': 2}
[Link]()
print(d) # Output: {}
2. [Link]()
Returns a shallow copy of the dictionary.
d1 = {'a': 1, 'b': 2}
d2 = [Link]()
print(d2) # Output: {'a': 1, 'b': 2}
3. [Link](iterable, value=None)
Creates a new dictionary with keys from the iterable and all values set to value.
keys = ['a', 'b', 'c']
d = [Link](keys, 0)
print(d) # Output: {'a': 0, 'b': 0, 'c': 0}
4. [Link](key, default=None)
Returns the value for key if present, else returns default.
d = {'a': 1, 'b': 2}
print([Link]('a')) # Output: 1
print([Link]('c', 'NA')) # Output: NA
5. [Link]()
Returns a view of key-value pairs.
d = {'a': 1, 'b': 2}
print(list([Link]())) # Output: [('a', 1), ('b', 2)]
6. [Link]()
Returns a view of keys.
d = {'a': 1, 'b': 2}
print(list([Link]())) # Output: ['a', 'b']
7. [Link]()
Returns a view of values.
d = {'a': 1, 'b': 2}
print(list([Link]())) # Output: [1, 2]
8. [Link](key, default)
Removes the specified key and returns its value. Returns default if key not found.
d = {'a': 1, 'b': 2}
print([Link]('a')) # Output: 1
print(d) # Output: {'b': 2}
print([Link]('x', 0)) # Output: 0
9. [Link]()
Removes and returns the last inserted key-value pair (in Python 3.7+).
d = {'a': 1, 'b': 2}
print([Link]()) # Output: ('b', 2)
print(d) # Output: {'a': 1}
10. [Link](key, default=None)
Returns the value of the key if it exists, otherwise inserts the key with default value.
d = {'a': 1}
print([Link]('a', 0)) # Output: 1
print([Link]('b', 2)) # Output: 2
print(d) # Output: {'a': 1, 'b': 2}
11. [Link](other_dict_or_iterable)
Updates the dictionary with key-value pairs from another dictionary or iterable.
d = {'a': 1}
[Link]({'b': 2, 'c': 3})
print(d) # Output: {'a': 1, 'b': 2, 'c': 3}
12. [Link]()
Returns all values in the dictionary.
d = {'a': 1, 'b': 2}
print(list([Link]())) # Output: [1, 2]