What Is Dictionary In Python?
Why Use A Python Dictionary?
Dictionary vs Lists
www.edureka.co/python
How To Implement Python Dictionary?
Operations In Python Dictionary
Use Case
www.edureka.co/python
www.edureka.co/python
A dictionary is a collection data type which has key value pairs.
UNORDERED
MUTABLE
INDEXED
NO DUPLICATE MEMBERS
www.edureka.co/python
Why Use A
Python
Dictionary?
www.edureka.co/python
Unordered and stores values like a map
Contains key value pairs unlike other
data types
Similar to real life dictionary with
distinct key values
www.edureka.co/python
Dictionary
Vs
Lists
www.edureka.co/python
Dictionary List
Unordered Ordered
Accesses via keys Accessed via index
Collection of key value pairs Collection of elements
Preferred when you have
unique key values
Preferred for ordered data
No duplicate members Allows duplicate members
How To Implement Dictionary In Python?
www.edureka.co/python
How To
Implement
Dictionary In
Python?
www.edureka.co/python
Dictionary in python is declared inside curly brackets.
mydictionary = { ‘key’ : ‘value’,
‘key2’: ‘value2’,
‘key3’: ‘value3’
}
mydictionary[‘key’]
mydictionary.get(‘key’)
www.edureka.co/python
Operations
In Python
Dictionary
www.edureka.co/python
#adding an element
mydictionary[‘key4’] = ‘value4’
#replacing an element
mydictionary[‘key1’] = ‘edureka’
• clear()
• copy()
• values()
• update()
• fromkeys()
• get()
• items()
• keys()
• pop()
• popitem()
• setdefault()
www.edureka.co/python
Use Case
www.edureka.co/python
Problem Statement : Store the Indian World cup squad data
for 2019.You should be able to display the stats of any player
from the data.
Store the data in the dictionary
Implement a dictionary
Import pandas package
Make unique keys
Use data frame to display stats
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
www.edureka.co
www.edureka.co/python

What is Dictionary In Python? Python Dictionary Tutorial | Edureka