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

Dictionary Functions

The document lists various functions that can be used with dictionaries in Python, along with their formats. Functions include 'len' for length, 'min' and 'max' for minimum and maximum elements, 'sum' for total, and methods for accessing keys, values, and items. It also describes functions for modifying dictionaries, such as 'copy', 'clear', 'pop', and 'update'.

Uploaded by

yuvalvermauv
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)
20 views1 page

Dictionary Functions

The document lists various functions that can be used with dictionaries in Python, along with their formats. Functions include 'len' for length, 'min' and 'max' for minimum and maximum elements, 'sum' for total, and methods for accessing keys, values, and items. It also describes functions for modifying dictionaries, such as 'copy', 'clear', 'pop', and 'update'.

Uploaded by

yuvalvermauv
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

FUNCTIONS IN DICTIONARIES :

Name Function Format

len - tells length of a dictionary


len(d1)
min - displays min element of dictionary
min(d1)
max - displays max element of dictionary
max(d1)
sum - displays sum of elements in a dictionary
sum(d1)
get - displays value of any particular key
[Link](key)
items - displays a sequence of (key,value) in pairs
[Link]()
keys - displays all the keys in a dictionary
[Link]()
values - displays all the values in a dictionary
[Link]()
copy - creates a copy of dictionary
[Link]()
clear - removes everything from the dictionary
[Link]()
sorted - sorts keys in ascending/descending order
sorted(d1)/sorted(d1,reverse=True)
popitem - removes and displays the last pair of dictionary
[Link]()
pop - removes any particular pair on basis on key entered
[Link]()
fromkeys - creates a new dictionary of entered key and value
[Link](key,value)
setdefault - inserts new key:value pair in already existing dictionary
[Link](key,value)
update - adds elements of other dict (d2) to main dict (d1)
[Link](d2)

You might also like