SlideShare a Scribd company logo
1 of 42
CHAPTER 14
DICTIONARIES
Unit 2:
Computational Thinking and Programming
XI
Computer Science (083)
Board : CBSE
Courtesy CBSE
LEARNING OUTCOMES
After studying this lesson, students
will be able to:
 Understand the need of dictionaries;
Solve problems by using dictionaries;
Get clear idea about dictionaries functions;
and
 Understand the difference between list and
dictionary.
LEARNING OUTCOMES
WHAT IS DICTIONARY?
A dictionary is like a list, but more in
general. In a list, index value is an integer, while
in a dictionary index value can be any other data
type and are called keys. The key will be used as
a string as it is easy to recall. A dictionary is an
extremely useful data storage construct for
storing and retrieving all key value pairs, where
each element is accessed (or indexed) by a
unique key. However, dictionary keys are not in
sequences and hence maintain no left-to right
order.
WHAT IS DICTIONARY?
We can refer to a dictionary as a
mapping between a set of indices (which
are called keys) and a set of values. Each
key maps a value. The association of a key
and a value is called a key-value pair.
Syntax:
my_dict = {'key1': 'value1','key2':
'value2','key3': 'value3'…'keyn': 'valuen'}
KEY VALYE PAIR
Curley brackets are used to represent a
dictionary.
Each pair in the dictionary is
represented by a key and value separated by a
colon.
Multiple pairs are separated by vcomas
DICTIONARIES
A dictionary is an unordered collection of key-
value pairs.
A dictionary has a length, specifically the numb
er of keyvalue pairs.
A dictionary provides fast look up by key.
The keys must be immutable object types.
DICTIONARIES
>>> A={1:"one",2:"two",3:"three"}
STATE DIAGRAM
A =
1 one
2 two
3 three
KEYS VALUES
CREATING A DICTIONARY – dict()
CREATING DICTIONARAY – dict()
The function dict ( ) is used to create a
new dictionary with no items. This function is
called built-in function. We can also create
dictionary using {}.
CREATING DICTIONARAY – Example
CREATING AND TRAVERSING DICTIONARAY
CREATING AND TRAVERSING DICTIONARAY
OUT PUT
CREATING AND TRAVERSING DICTIONARAY
OUT PUT
DICTIONARAY – BUILT IN METHODS
DICTIONARAY – BUILT IN METHODS
Dictionary Method Meaning
dict.clear() Removes all the elements of the
dictionary
dict.copy() Returns (shallow)copy of
dictionary.
dict.get(key,
default=None)
for key key, returns value or
default if key not in dictionary
(note that default's default is
None)
dict.items() returns a list of dict's (key, value)
tuple pairs
Dictionary Method Meaning
dict.keys() returns list of dictionary dict's
keys
dict.setdefault key,
default=None
similar to get(), but will set
dict[key]=default if key is not
already in dict
dict.update(dict2) adds dictionary dict2's key-values
pairs to dict
dict.values() returns list of dictionary dict's
values
DICTIONARAY – BUILT IN METHODS
Dictionary Method Meaning
dict.pop() returns list of dictionary dict's
keys
dict.popitem() similar to get(), but will set
dict[key]=default if key is not
already in dict
DICTIONARAY – BUILT IN METHODS
dict.clear() METHOD
clear method
OUTPUT is in next slide!
dict.clear() METHOD - OUTPUT
Birthday dictionary cleared
dict.copy() METHOD
copy method
OUTPUT is in next slide!
dict.copy() METHOD - OUTPUT
copy method creates b2 dictionary
dict.get() METHOD
OUTPUT is in next slide!
get method
dict.get() METHOD - OUTPUT
Creating a b2 dictionary using get method
dict.items() METHOD
OUTPUT is in next slide!
items method
dict.items() METHOD - OUTPUT
items method returns dictionary content
dict.keys() METHOD
OUTPUT is in next slide!
keys method
dict.keys() METHOD - OUTPUT
keys method returns dictionary keys
dict.update() METHOD
update method
dict.values() METHOD
values method returns dictionary values
dict.pop() METHOD
pop method removes specified key
values from the dictionary
dict.popitem() METHOD
popitem method removes values/items
from the dictionary
CLASS WORK/HOME WORK
CLASS WORK/HOME WORK
1. Write a Python script to sort (ascending and
descending) a dictionary by value.
2. Write a Python script to add a key to a dictionary.
Sample Dictionary : {0: 10, 1: 20}
Expected Result : {0: 10, 1: 20, 2: 30}
3. Write a Python script to concatenate following
dictionaries to create a new one.
Sample Dictionary :
dic1={1:10, 2:20}
dic2={3:30, 4:40}
dic3={5:50,6:60}
Expected Result : {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6:
60}
CLASS WORK/HOME WORK
4. Write a Python script to check if a given key
already exists in a dictionary.
5. Write a Python program to iterate over
dictionaries using for loops.
6. Write a Python script to generate and print a
dictionary that contains a number (between 1 and
n) in the form (x, x*x).
Sample Dictionary ( n = 5) :
Expected Output : {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
CLASS WORK/HOME WORK
7. Write a Python script to print a dictionary where
the keys are numbers between 1 and 15 (both
included) and the values are square of keys.
Sample Dictionary
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81,
10: 100, 11: 121, 12: 144, 13: 169, 14: 196, 15: 225}
8. Write a Python script to merge two Python
dictionaries.
CLASS WORK/HOME WORK
9. Write a Python program to iterate over
dictionaries using for loops.
10. Write a Python program to sum all the items in
a dictionary.
Class Test
Class Test
Time: 40 Min Max Marks: 20
1. What is dictionary? give example 02
2. Write a python script to traverse a
dictionary 05
3. Explain 5 list built in methods of
dictionary 10
4. What is key value pair? Explain 05
Thank You

More Related Content

Similar to Chapter 14 Dictionary.pptx

Collections in Python - Where Data Finds Its Perfect Home.pdf
Collections in Python - Where Data Finds Its Perfect Home.pdfCollections in Python - Where Data Finds Its Perfect Home.pdf
Collections in Python - Where Data Finds Its Perfect Home.pdfSudhanshiBakre1
 
Dictionaries and Sets in Python
Dictionaries and Sets in PythonDictionaries and Sets in Python
Dictionaries and Sets in PythonRaajendra M
 
PE1 Module 4.ppt
PE1 Module 4.pptPE1 Module 4.ppt
PE1 Module 4.pptbalewayalew
 
Dictionary part 1
Dictionary part 1Dictionary part 1
Dictionary part 1RishuKaul2
 
Week 10.pptx
Week 10.pptxWeek 10.pptx
Week 10.pptxCruiseCH
 
Mapping Data Types In Python.pptx
Mapping Data Types In Python.pptxMapping Data Types In Python.pptx
Mapping Data Types In Python.pptxAnveshbandalla
 
Python03 course in_mumbai
Python03 course in_mumbaiPython03 course in_mumbai
Python03 course in_mumbaivibrantuser
 
PRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptxPRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptxabhishek364864
 
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScriptLotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScriptBill Buchan
 
Ch 7 Dictionaries 1.pptx
Ch 7 Dictionaries 1.pptxCh 7 Dictionaries 1.pptx
Ch 7 Dictionaries 1.pptxKanchanaRSVVV
 

Similar to Chapter 14 Dictionary.pptx (20)

Collections in Python - Where Data Finds Its Perfect Home.pdf
Collections in Python - Where Data Finds Its Perfect Home.pdfCollections in Python - Where Data Finds Its Perfect Home.pdf
Collections in Python - Where Data Finds Its Perfect Home.pdf
 
Dictionaries and Sets in Python
Dictionaries and Sets in PythonDictionaries and Sets in Python
Dictionaries and Sets in Python
 
Unit 1(Lesson7).pptx
Unit 1(Lesson7).pptxUnit 1(Lesson7).pptx
Unit 1(Lesson7).pptx
 
PE1 Module 4.ppt
PE1 Module 4.pptPE1 Module 4.ppt
PE1 Module 4.ppt
 
Dictionary part 1
Dictionary part 1Dictionary part 1
Dictionary part 1
 
Week 10.pptx
Week 10.pptxWeek 10.pptx
Week 10.pptx
 
Mapping Data Types In Python.pptx
Mapping Data Types In Python.pptxMapping Data Types In Python.pptx
Mapping Data Types In Python.pptx
 
Dictionary.pptx
Dictionary.pptxDictionary.pptx
Dictionary.pptx
 
Python03 course in_mumbai
Python03 course in_mumbaiPython03 course in_mumbai
Python03 course in_mumbai
 
PRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptxPRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptx
 
Python dictionaries
Python dictionariesPython dictionaries
Python dictionaries
 
PYTHON 101.pptx
PYTHON 101.pptxPYTHON 101.pptx
PYTHON 101.pptx
 
Amusing C#
Amusing C#Amusing C#
Amusing C#
 
Lecture1
Lecture1Lecture1
Lecture1
 
Understanding Python
Understanding PythonUnderstanding Python
Understanding Python
 
Python Lecture 10
Python Lecture 10Python Lecture 10
Python Lecture 10
 
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScriptLotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScript
 
Dictionary
DictionaryDictionary
Dictionary
 
14 Skip Lists
14 Skip Lists14 Skip Lists
14 Skip Lists
 
Ch 7 Dictionaries 1.pptx
Ch 7 Dictionaries 1.pptxCh 7 Dictionaries 1.pptx
Ch 7 Dictionaries 1.pptx
 

Recently uploaded

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 

Recently uploaded (20)

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 

Chapter 14 Dictionary.pptx

  • 2. Unit 2: Computational Thinking and Programming XI Computer Science (083) Board : CBSE Courtesy CBSE
  • 4. After studying this lesson, students will be able to:  Understand the need of dictionaries; Solve problems by using dictionaries; Get clear idea about dictionaries functions; and  Understand the difference between list and dictionary. LEARNING OUTCOMES
  • 6. A dictionary is like a list, but more in general. In a list, index value is an integer, while in a dictionary index value can be any other data type and are called keys. The key will be used as a string as it is easy to recall. A dictionary is an extremely useful data storage construct for storing and retrieving all key value pairs, where each element is accessed (or indexed) by a unique key. However, dictionary keys are not in sequences and hence maintain no left-to right order. WHAT IS DICTIONARY?
  • 7. We can refer to a dictionary as a mapping between a set of indices (which are called keys) and a set of values. Each key maps a value. The association of a key and a value is called a key-value pair. Syntax: my_dict = {'key1': 'value1','key2': 'value2','key3': 'value3'…'keyn': 'valuen'} KEY VALYE PAIR
  • 8. Curley brackets are used to represent a dictionary. Each pair in the dictionary is represented by a key and value separated by a colon. Multiple pairs are separated by vcomas DICTIONARIES
  • 9. A dictionary is an unordered collection of key- value pairs. A dictionary has a length, specifically the numb er of keyvalue pairs. A dictionary provides fast look up by key. The keys must be immutable object types. DICTIONARIES
  • 10. >>> A={1:"one",2:"two",3:"three"} STATE DIAGRAM A = 1 one 2 two 3 three KEYS VALUES
  • 11. CREATING A DICTIONARY – dict()
  • 12. CREATING DICTIONARAY – dict() The function dict ( ) is used to create a new dictionary with no items. This function is called built-in function. We can also create dictionary using {}.
  • 14. CREATING AND TRAVERSING DICTIONARAY
  • 15. CREATING AND TRAVERSING DICTIONARAY OUT PUT
  • 16. CREATING AND TRAVERSING DICTIONARAY OUT PUT
  • 17. DICTIONARAY – BUILT IN METHODS
  • 18. DICTIONARAY – BUILT IN METHODS Dictionary Method Meaning dict.clear() Removes all the elements of the dictionary dict.copy() Returns (shallow)copy of dictionary. dict.get(key, default=None) for key key, returns value or default if key not in dictionary (note that default's default is None) dict.items() returns a list of dict's (key, value) tuple pairs
  • 19. Dictionary Method Meaning dict.keys() returns list of dictionary dict's keys dict.setdefault key, default=None similar to get(), but will set dict[key]=default if key is not already in dict dict.update(dict2) adds dictionary dict2's key-values pairs to dict dict.values() returns list of dictionary dict's values DICTIONARAY – BUILT IN METHODS
  • 20. Dictionary Method Meaning dict.pop() returns list of dictionary dict's keys dict.popitem() similar to get(), but will set dict[key]=default if key is not already in dict DICTIONARAY – BUILT IN METHODS
  • 22. dict.clear() METHOD - OUTPUT Birthday dictionary cleared
  • 24. dict.copy() METHOD - OUTPUT copy method creates b2 dictionary
  • 25. dict.get() METHOD OUTPUT is in next slide! get method
  • 26. dict.get() METHOD - OUTPUT Creating a b2 dictionary using get method
  • 27. dict.items() METHOD OUTPUT is in next slide! items method
  • 28. dict.items() METHOD - OUTPUT items method returns dictionary content
  • 29. dict.keys() METHOD OUTPUT is in next slide! keys method
  • 30. dict.keys() METHOD - OUTPUT keys method returns dictionary keys
  • 32. dict.values() METHOD values method returns dictionary values
  • 33. dict.pop() METHOD pop method removes specified key values from the dictionary
  • 34. dict.popitem() METHOD popitem method removes values/items from the dictionary
  • 36. CLASS WORK/HOME WORK 1. Write a Python script to sort (ascending and descending) a dictionary by value. 2. Write a Python script to add a key to a dictionary. Sample Dictionary : {0: 10, 1: 20} Expected Result : {0: 10, 1: 20, 2: 30} 3. Write a Python script to concatenate following dictionaries to create a new one. Sample Dictionary : dic1={1:10, 2:20} dic2={3:30, 4:40} dic3={5:50,6:60} Expected Result : {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}
  • 37. CLASS WORK/HOME WORK 4. Write a Python script to check if a given key already exists in a dictionary. 5. Write a Python program to iterate over dictionaries using for loops. 6. Write a Python script to generate and print a dictionary that contains a number (between 1 and n) in the form (x, x*x). Sample Dictionary ( n = 5) : Expected Output : {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
  • 38. CLASS WORK/HOME WORK 7. Write a Python script to print a dictionary where the keys are numbers between 1 and 15 (both included) and the values are square of keys. Sample Dictionary {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100, 11: 121, 12: 144, 13: 169, 14: 196, 15: 225} 8. Write a Python script to merge two Python dictionaries.
  • 39. CLASS WORK/HOME WORK 9. Write a Python program to iterate over dictionaries using for loops. 10. Write a Python program to sum all the items in a dictionary.
  • 41. Class Test Time: 40 Min Max Marks: 20 1. What is dictionary? give example 02 2. Write a python script to traverse a dictionary 05 3. Explain 5 list built in methods of dictionary 10 4. What is key value pair? Explain 05