dictionary in python
1]dictionary is a collection of key-value pairs enclosed in curly brackets, separated by comma.
2]dictionary is a mutable datatype.
3]The keys of dictionary is always immutable by nature. Dictionary has 2 operations and 7 methods as follows
Operations in dictionary
1] get : It returns value you stored in the key that you enter in square box.
2] update : It adds a new key value pair to the dictionary, or updates already present pair.
methods in dictionary
1] .keys() : It returns the keys available in the dictionary.
2].values() : It returns the values located in the keys available in the dictionary.
3] .items() : it returns both key and value pairs .
4] .get() — It returns the value assigned to a key which is passed as argument in the method.
5] . setdefault() : It adds a key value pairs to the dictionary which are unique and not present in dictionary. It doesn’t update any key value pair which is present in the dictionary already & returns present value of the key when we try to update.
6] .update() : It adds a unique key & value pair to the dictionary. In the event, key being added is already present in the dictionary then it’ll update the value of that pair.
7] .pop() : It removes the key value pair or item, when the respective key is given as argument to the method.