Dictionary Handling in Python – Notes

Dictionary Handling in Python


Topics

Dictionary: introduction, accessing items in a dictionary using keys, mutability of dictionary (adding a new item, modifying an existing item), traversing a dictionary, built-in functions: len(), dict(), keys(), values(), items(), get(), update(), del(), clear(), fromkeys(), copy(), pop(), popitem(), setdefault(), max(), min(), count(), sorted(), copy();

Suggested programs : count the number of times a character appears in a given string using a dictionary, create a dictionary with names of employees, their salary and access them


What is Dictionary ?

Accessing items in a dictionary using keys

Mutability of dictionary :-

a) Adding a new item,

b) Modifying an existing item)

Traversing a dictionary

Built-in functions:

len(),

dict(),

keys(),

values(),

items(),

get(),

update(),

del(),

clear(),

fromkeys(),

copy(),

pop(),

popitem(),

setdefault(),

max(),

min(),

count(),

sorted(),

copy();

Suggested programs :

1. Count the number of times a character appears in a given string using a dictionary.

2. create a dictionary with the names of employees, and their salaries and access them.

Leave a Comment

You cannot copy content of this page

Scroll to Top