SlideShare a Scribd company logo
6
Most read
8
Most read
11
Most read
Dictionaries in Python
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
Week Target Achieved
1 40 23
2 40 26
3
Typing Speed
Jobs Applied
# Company Designation Applied Date Current
Status
1
2
3
Dictionaries in Python
shafeeque
●
shafeequemonp@gmail.com
●
www.facebook.com/shafeequemonppambodan
●
twitter.com/shafeequemonp
●
in.linkedin.com/in/shafeequemonp
●
9809611325
Python Dictionary:
● A dictionary is mutable and is another container type that can
store any number of Python objects
● Dictionaries consist of pairs (called items) of keys and their
corresponding values.
● Python dictionaries are also known as associative arrays or
hash tables.
● The general syntax of a dictionary is as follows:
● dict = {'A': '2341', 'B': '9102', 'C': '3258'}
Python Dictionary Features:
● Each key is separated from its value by a colon (:).
● The items are separated by commas, and the whole thing is
enclosed in curly braces.
● An empty dictionary without any items is written with just two
curly braces, like this: {}.
● Keys are unique within a dictionary while values may not be
● The values of a dictionary can be of any type, but the keys
must be of an immutable data type such as strings, numbers,
or tuples.
Accessing Values in Dictionary:
● To access dictionary elements, you can use the familiar
square brackets along with the key to obtain its value.
● For example:
● dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'};
print "dict['Name']: ", dict['Name'];
● Output:
dict['Name']: Zara
Updating Dictionary:
●You can update a dictionary by adding a new entry or item (i.e., a key-value pair)
I.e:
●modifying an existing entry, or deleting an existing entry as shown below in the
simple example
●dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'};
dict['Age'] = 8; # update existing entry
dict['School'] = "DPS School"; # Add new entry
print "dict['Age']: ", dict['Age'];
print "dict['School']: ", dict['School'];
●Output:
dict['Age']: 8
●dict['School']: DPS School
Delete Dictionary Elements:
You can either remove individual dictionary elements or clear the entire
contents of a dictionary
● To explicitly remove an entire dictionary, just use the del statement.
i.e:
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'};
● del dict['Name']; # remove entry with key 'Name'
dict.clear(); # remove all entries in dict
del dict ; # delete entire dictionary
● print "dict['Age']: ", dict['Age'];
● print "dict['School']: ", dict['School'];
output:dict['Age']:
Traceback (most recent call last):
File "test.py", line 8, in <module>
print "dict['Age']: ", dict['Age'];
TypeError: 'type' object is unsubscriptable
Properties of Dictionary Keys:
● There are two important points to remember about dictionary keys:
● (a) More than one entry per key not allowed. Which means no duplicate key is allowed.
When duplicate keys encountered during assignment, the last assignment wins.
● i.e:
● dict = {'Name': 'Zara', 'Age': 7, 'Name': 'Manni'};
print "dict['Name']: ", dict['Name'];
● Output:
● dict['Name']: Manni
● (b) Keys must be immutable. Which means you can use strings, numbers, or tuples as
dictionary keys but something like ['key'] is not allowed. Following is a simple example:
● dict = {['Name']: 'Zara', 'Age': 7};
● print "dict['Name']: ", dict['Name']; output:Traceback (most recent call last):
File "test.py", line 3, in <module>
ict = {['Name']: 'Zara', 'Age': 7};
TypeError: list objects are unhashable
If this presentation helped you, please visit our page facebook.com/baabtra and
like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

More Related Content

PPTX
Modules in Python Programming
PDF
Strings in python
PPTX
Chapter 05 classes and objects
PPTX
Python dictionary
PPTX
Python dictionary
PPTX
Data Structures in Python
PDF
Python programming : Classes objects
Modules in Python Programming
Strings in python
Chapter 05 classes and objects
Python dictionary
Python dictionary
Data Structures in Python
Python programming : Classes objects

What's hot (20)

PPTX
Python dictionary
PDF
Python set
PPTX
Data types in python
PDF
Python strings
PPTX
Python Functions
PPTX
PPTX
List in Python
PPTX
String, string builder, string buffer
PPTX
Class, object and inheritance in python
PPTX
Inheritance in java
PPTX
Variables in python
PPTX
STRINGS IN PYTHON
PDF
Python list
PPTX
Interface in java
PPTX
Functions in python slide share
PDF
Python functions
PPTX
Python variables and data types.pptx
PPTX
Method overloading
Python dictionary
Python set
Data types in python
Python strings
Python Functions
List in Python
String, string builder, string buffer
Class, object and inheritance in python
Inheritance in java
Variables in python
STRINGS IN PYTHON
Python list
Interface in java
Functions in python slide share
Python functions
Python variables and data types.pptx
Method overloading
Ad

Viewers also liked (10)

PDF
Python Workshop Part 2. LUG Maniapl
PDF
Class 6: Lists & dictionaries
PPTX
An Introduction To Python - Dictionaries
PPTX
PPTX
Python Programming Essentials - M12 - Lists
PPSX
Programming with Python
PPT
Introduction to Python
Python Workshop Part 2. LUG Maniapl
Class 6: Lists & dictionaries
An Introduction To Python - Dictionaries
Python Programming Essentials - M12 - Lists
Programming with Python
Introduction to Python
Ad

Similar to Dictionaries in Python (20)

PPTX
Dictionary.pptx
PPTX
Ch 7 Dictionaries 1.pptx
PPTX
Python Fundamental Data structures: Dictionaries
PPTX
PYTHON Data structures Fundamentals: DICTIONARIES
PDF
CHAPTER- 9 PYTHON DICTIONARIES.pdf computer science
PPTX
dictionary14 ppt FINAL.pptx
PPTX
Dictionariesasdfghjsdfghjklsdfghjkl.pptx
PDF
Dictionaries in Python programming for btech students
PPTX
Dictionary in python Dictionary in python Dictionary in pDictionary in python...
PPTX
Untitled dictionary in python program .pdf.pptx
PPTX
DICTIONARIES (1).pptx
PDF
Python dictionaries
PPTX
Unit4-Basic Concepts and methods of Dictionary.pptx
PDF
Dictionary part 1
PDF
Programming in python Unit-1 Part-1
PDF
Python Dictionary
PPTX
Dictionary in python
PPTX
Session10_Dictionaries.ppggyyyyyyyyyggggggggtx
PPTX
Python in easy way It includes different data type
Dictionary.pptx
Ch 7 Dictionaries 1.pptx
Python Fundamental Data structures: Dictionaries
PYTHON Data structures Fundamentals: DICTIONARIES
CHAPTER- 9 PYTHON DICTIONARIES.pdf computer science
dictionary14 ppt FINAL.pptx
Dictionariesasdfghjsdfghjklsdfghjkl.pptx
Dictionaries in Python programming for btech students
Dictionary in python Dictionary in python Dictionary in pDictionary in python...
Untitled dictionary in python program .pdf.pptx
DICTIONARIES (1).pptx
Python dictionaries
Unit4-Basic Concepts and methods of Dictionary.pptx
Dictionary part 1
Programming in python Unit-1 Part-1
Python Dictionary
Dictionary in python
Session10_Dictionaries.ppggyyyyyyyyyggggggggtx
Python in easy way It includes different data type

More from baabtra.com - No. 1 supplier of quality freshers (20)

PPTX
Agile methodology and scrum development
PDF
Acquiring new skills what you should know
PDF
Baabtra.com programming at school
PDF
99LMS for Enterprises - LMS that you will love
PPTX
Chapter 6 database normalisation
PPTX
Chapter 5 transactions and dcl statements
PPTX
Chapter 4 functions, views, indexing
PPTX
PPTX
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
PPTX
Chapter 1 introduction to sql server
PPTX
Chapter 1 introduction to sql server
Agile methodology and scrum development
Acquiring new skills what you should know
Baabtra.com programming at school
99LMS for Enterprises - LMS that you will love
Chapter 6 database normalisation
Chapter 5 transactions and dcl statements
Chapter 4 functions, views, indexing
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 1 introduction to sql server
Chapter 1 introduction to sql server

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PDF
Empathic Computing: Creating Shared Understanding
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Spectroscopy.pptx food analysis technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
Teaching material agriculture food technology
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Electronic commerce courselecture one. Pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
Machine learning based COVID-19 study performance prediction
Empathic Computing: Creating Shared Understanding
Advanced methodologies resolving dimensionality complications for autism neur...
Spectral efficient network and resource selection model in 5G networks
Unlocking AI with Model Context Protocol (MCP)
Spectroscopy.pptx food analysis technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Building Integrated photovoltaic BIPV_UPV.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
MIND Revenue Release Quarter 2 2025 Press Release
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
MYSQL Presentation for SQL database connectivity
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
20250228 LYD VKU AI Blended-Learning.pptx
Teaching material agriculture food technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Electronic commerce courselecture one. Pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm

Dictionaries in Python

  • 2. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 3. Week Target Achieved 1 40 23 2 40 26 3 Typing Speed
  • 4. Jobs Applied # Company Designation Applied Date Current Status 1 2 3
  • 6. Python Dictionary: ● A dictionary is mutable and is another container type that can store any number of Python objects ● Dictionaries consist of pairs (called items) of keys and their corresponding values. ● Python dictionaries are also known as associative arrays or hash tables. ● The general syntax of a dictionary is as follows: ● dict = {'A': '2341', 'B': '9102', 'C': '3258'}
  • 7. Python Dictionary Features: ● Each key is separated from its value by a colon (:). ● The items are separated by commas, and the whole thing is enclosed in curly braces. ● An empty dictionary without any items is written with just two curly braces, like this: {}. ● Keys are unique within a dictionary while values may not be ● The values of a dictionary can be of any type, but the keys must be of an immutable data type such as strings, numbers, or tuples.
  • 8. Accessing Values in Dictionary: ● To access dictionary elements, you can use the familiar square brackets along with the key to obtain its value. ● For example: ● dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}; print "dict['Name']: ", dict['Name']; ● Output: dict['Name']: Zara
  • 9. Updating Dictionary: ●You can update a dictionary by adding a new entry or item (i.e., a key-value pair) I.e: ●modifying an existing entry, or deleting an existing entry as shown below in the simple example ●dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}; dict['Age'] = 8; # update existing entry dict['School'] = "DPS School"; # Add new entry print "dict['Age']: ", dict['Age']; print "dict['School']: ", dict['School']; ●Output: dict['Age']: 8 ●dict['School']: DPS School
  • 10. Delete Dictionary Elements: You can either remove individual dictionary elements or clear the entire contents of a dictionary ● To explicitly remove an entire dictionary, just use the del statement. i.e: dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}; ● del dict['Name']; # remove entry with key 'Name' dict.clear(); # remove all entries in dict del dict ; # delete entire dictionary ● print "dict['Age']: ", dict['Age']; ● print "dict['School']: ", dict['School']; output:dict['Age']: Traceback (most recent call last): File "test.py", line 8, in <module> print "dict['Age']: ", dict['Age']; TypeError: 'type' object is unsubscriptable
  • 11. Properties of Dictionary Keys: ● There are two important points to remember about dictionary keys: ● (a) More than one entry per key not allowed. Which means no duplicate key is allowed. When duplicate keys encountered during assignment, the last assignment wins. ● i.e: ● dict = {'Name': 'Zara', 'Age': 7, 'Name': 'Manni'}; print "dict['Name']: ", dict['Name']; ● Output: ● dict['Name']: Manni ● (b) Keys must be immutable. Which means you can use strings, numbers, or tuples as dictionary keys but something like ['key'] is not allowed. Following is a simple example: ● dict = {['Name']: 'Zara', 'Age': 7}; ● print "dict['Name']: ", dict['Name']; output:Traceback (most recent call last): File "test.py", line 3, in <module> ict = {['Name']: 'Zara', 'Age': 7}; TypeError: list objects are unhashable
  • 12. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 13. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com