[go: up one dir, main page]

0% found this document useful (0 votes)
5 views1 page

Dictionary

Uploaded by

jayshree.a2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Dictionary

Uploaded by

jayshree.a2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

DICTIONARY

1.keys-To get all the keys in dictionary


command: d.keys()
2.values-to get all the values in dictionary
command: d.values()
3.items-shows the dictionary as a set
command: d.items()
4.get-to obtain the value by giving a key
command: d.get(key)
5.setdefault-where a new key is added with a default value-'none'
command: d.setdefault(key)
6.update-where a new key and it's corresponding value can be updated
command: d.update({key:value})
7.copy-it copies the dictionary
(i)deep copy- where changes can be reflected after copying the dictionary
command: d1=d
(ii)shallow copy-where changes cannot be reflected,copies the original
dictionary rather than the updated one
command: d.copy()
8.fromkeys-where multiple keys are given to represent the same value
command: d.fromkeys([keys],value)
9.pop-where it pops out the key and it's corresponding value specified
command: d.pop(key)
10.popitem-where it pops out the last key and it's value of the dictionary
command: d.popitem()
11.clear-clears out the entire dictionary
command: d.clear()

You might also like