SlideShare uma empresa Scribd logo
1 de 12
Baixar para ler offline
Dictionaries (Hash Maps)
Python dictionaries are unordered collection of pairs in the form of key:value.
e.g. L=[ 2,4,5,6,10 ]
print(L[2])
D = { 'dog' : 'friendly' , 'lion' : 'wild' , 'parrot' : 'funny' }
print( D['dog'] )
Dictionaries
● It’s an unordered set of key:value pairs.
● Dictionaries are mutable.
● Unlike a string, list & tuple. A dictionary is not a sequence, it’s
unordered set of elements.
● All keys must be unique.
● We can change the value of any key :
D[<key>] = <new value>
Playing with Dictionaries
■ Walking in a Dictionary
To traverse in a dictionary we can use the for loop.
for <variable> in <dictionary> :
print(<variable>)
for i in d :
print( i, ':', d[i] )
D = { 'dog' : 'friendly' , 'lion' : 'wild' , 'parrot' : 'funny' }
Playing with Dictionaries
■ Adding an element
D['monkey'] = 'Human-Like'
■ Updating an element
D[ 'parrot'] ='Sometimes-funny' ✔
D['bat' ] ='Not-for-eating' ❌
■ Deleting an element
del <dictionary>[<key>] del d['lion']
<dictionary>.pop(<key>) d.pop('lion')
Pop method also returns the deleted element.
print(d.pop('lion'))
■ Checking existence of a key
‘lion’ in d --- true
‘tiger’ in d --- false
Playing with Dictionaries
■ The len( ) method
len( <dictionary> ) --- gives the count of pairs
■ The clear( ) method
<dictionary>.clear( ) --- clears the whole dictionary.
■ The get( ) method
print(d.get(‘lion’)) --- print(d[‘lion’])
■ The keys( ) method
print(d.keys( )) --- displays all the keys
Dictionaries Functions
■ The items( ) method
This method returns all the pairs as a sequence of (key,value) tuples.
(in no particular order).
L=d.items( )
print(L) --- [('dog' , 'friendly'),('lion' , 'wild'),('parrot' , 'funny')]
■ The values( ) method
<dictionary>.values( ) --- returns all the values.
Dictionaries Functions
Dictionaries Functions
■ The update( ) method
<dictionary>.update( <other-dictionary> )
<other-dictionary> will over-ride in <dictionary>.
● New Keys will be added.
● Existing key will be updated with new values.
e.g. d = { 'dog' : 'friendly' , 'lion' : 'wild' , 'parrot' : 'funny' }
d2= { 'dog' : pet' , 'lion' : 'wild' , tiger' : 'dangerous’ }
d.update(d2)
print(d)
{ 'dog' : pet' , 'lion' : 'wild' , 'parrot' : 'funny', ‘tiger’:’dangerous’ }
Practice Time
Q1. R={ 'Name' : 'Python', 'Age' : '20', 'Addr' : 'NJ' , 'Country' : 'USA' }
id1=id(R)
R2={ 'Name' : 'Python', 'Age' : '20', 'Addr' : 'NJ' , 'Country' : 'USA' }
id2=id(R2)
print(id1==id2) ( id( ) gives the address of the object )
Q2. D = { }
D[ (1,2,4) ] =8
D[ (4,2,1) ] =10
D[ (1,2) ] =12
sum = 0
for k in D:
sum+=D[k]
print(sum)
print(D)
Practice Time
1. W.a.p. to verify whether the phone number is in the given format
or not
( ex. 017-555-1212 is the correct format )
2. Write a program that prints the longest word in a list.
3. Write a python program that creates a list storing first 9 terms of
fibonacci series.
1, 1, 2, 3 ,5 ,8 ….
4. W.a.p. to make a list of all integers less than hundred which are
multiples of 3 or 5. --- H.W.
Practice Time
1. Write a function addDict(dict1, dict2) which computes the union of two
dictionaries. If same key appears in both, pick either one.
2. Create a dictionary whose keys are month names and whose values are
number of days in the corresponding months.
a. Ask user to enter month name and number of days.
b. Print out all of the keys in alphabetical order.
c. Print out all of the months with 31 days.
d. Print out the (key-value) pairs sorted by keys.
e. Print out the (key-value) pairs sorted by values. Typical
Lecture-6.pdf

Mais conteúdo relacionado

Semelhante a Lecture-6.pdf

Beginner's Python Cheat Sheet
Beginner's Python Cheat SheetBeginner's Python Cheat Sheet
Beginner's Python Cheat SheetVerxus
 
beginners_python_cheat_sheet_pcc_all (1).pdf
beginners_python_cheat_sheet_pcc_all (1).pdfbeginners_python_cheat_sheet_pcc_all (1).pdf
beginners_python_cheat_sheet_pcc_all (1).pdfElNew2
 
DICTIONARIES (1).pptx
DICTIONARIES (1).pptxDICTIONARIES (1).pptx
DICTIONARIES (1).pptxKalashJain27
 
An Introduction to Tuple List Dictionary in Python
An Introduction to Tuple List Dictionary in PythonAn Introduction to Tuple List Dictionary in Python
An Introduction to Tuple List Dictionary in Pythonyashar Aliabasi
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayUtkarsh Sengar
 
Basics of Python programming (part 2)
Basics of Python programming (part 2)Basics of Python programming (part 2)
Basics of Python programming (part 2)Pedro Rodrigues
 
Class 31: Deanonymizing
Class 31: DeanonymizingClass 31: Deanonymizing
Class 31: DeanonymizingDavid Evans
 
Beginners python cheat sheet - Basic knowledge
Beginners python cheat sheet - Basic knowledge Beginners python cheat sheet - Basic knowledge
Beginners python cheat sheet - Basic knowledge O T
 
2 UNIT CH3 Dictionaries v1.ppt
2 UNIT CH3 Dictionaries v1.ppt2 UNIT CH3 Dictionaries v1.ppt
2 UNIT CH3 Dictionaries v1.ppttocidfh
 
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdfGE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdfAsst.prof M.Gokilavani
 
STRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdfSTRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdfomprakashmeena48
 
beginners_python_cheat_sheet_pcc_all (3).pptx
beginners_python_cheat_sheet_pcc_all (3).pptxbeginners_python_cheat_sheet_pcc_all (3).pptx
beginners_python_cheat_sheet_pcc_all (3).pptxHongAnhNguyn285885
 
python chapter 1
python chapter 1python chapter 1
python chapter 1Raghu nath
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2Raghu nath
 

Semelhante a Lecture-6.pdf (20)

Beginner's Python Cheat Sheet
Beginner's Python Cheat SheetBeginner's Python Cheat Sheet
Beginner's Python Cheat Sheet
 
beginners_python_cheat_sheet_pcc_all (1).pdf
beginners_python_cheat_sheet_pcc_all (1).pdfbeginners_python_cheat_sheet_pcc_all (1).pdf
beginners_python_cheat_sheet_pcc_all (1).pdf
 
DICTIONARIES (1).pptx
DICTIONARIES (1).pptxDICTIONARIES (1).pptx
DICTIONARIES (1).pptx
 
An Introduction to Tuple List Dictionary in Python
An Introduction to Tuple List Dictionary in PythonAn Introduction to Tuple List Dictionary in Python
An Introduction to Tuple List Dictionary in Python
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
Basics of Python programming (part 2)
Basics of Python programming (part 2)Basics of Python programming (part 2)
Basics of Python programming (part 2)
 
Dictionary in python
Dictionary in pythonDictionary in python
Dictionary in python
 
Python lecture 05
Python lecture 05Python lecture 05
Python lecture 05
 
Class 31: Deanonymizing
Class 31: DeanonymizingClass 31: Deanonymizing
Class 31: Deanonymizing
 
Beginners python cheat sheet - Basic knowledge
Beginners python cheat sheet - Basic knowledge Beginners python cheat sheet - Basic knowledge
Beginners python cheat sheet - Basic knowledge
 
1. python
1. python1. python
1. python
 
Python cheatsheet for beginners
Python cheatsheet for beginnersPython cheatsheet for beginners
Python cheatsheet for beginners
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
2 UNIT CH3 Dictionaries v1.ppt
2 UNIT CH3 Dictionaries v1.ppt2 UNIT CH3 Dictionaries v1.ppt
2 UNIT CH3 Dictionaries v1.ppt
 
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdfGE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
 
STRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdfSTRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdf
 
beginners_python_cheat_sheet_pcc_all (3).pptx
beginners_python_cheat_sheet_pcc_all (3).pptxbeginners_python_cheat_sheet_pcc_all (3).pptx
beginners_python_cheat_sheet_pcc_all (3).pptx
 
python chapter 1
python chapter 1python chapter 1
python chapter 1
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
 

Último

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburgmasabamasaba
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 

Último (20)

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 

Lecture-6.pdf

  • 1. Dictionaries (Hash Maps) Python dictionaries are unordered collection of pairs in the form of key:value. e.g. L=[ 2,4,5,6,10 ] print(L[2]) D = { 'dog' : 'friendly' , 'lion' : 'wild' , 'parrot' : 'funny' } print( D['dog'] )
  • 2. Dictionaries ● It’s an unordered set of key:value pairs. ● Dictionaries are mutable. ● Unlike a string, list & tuple. A dictionary is not a sequence, it’s unordered set of elements. ● All keys must be unique. ● We can change the value of any key : D[<key>] = <new value>
  • 3. Playing with Dictionaries ■ Walking in a Dictionary To traverse in a dictionary we can use the for loop. for <variable> in <dictionary> : print(<variable>) for i in d : print( i, ':', d[i] ) D = { 'dog' : 'friendly' , 'lion' : 'wild' , 'parrot' : 'funny' }
  • 4. Playing with Dictionaries ■ Adding an element D['monkey'] = 'Human-Like' ■ Updating an element D[ 'parrot'] ='Sometimes-funny' ✔ D['bat' ] ='Not-for-eating' ❌
  • 5. ■ Deleting an element del <dictionary>[<key>] del d['lion'] <dictionary>.pop(<key>) d.pop('lion') Pop method also returns the deleted element. print(d.pop('lion')) ■ Checking existence of a key ‘lion’ in d --- true ‘tiger’ in d --- false Playing with Dictionaries
  • 6. ■ The len( ) method len( <dictionary> ) --- gives the count of pairs ■ The clear( ) method <dictionary>.clear( ) --- clears the whole dictionary. ■ The get( ) method print(d.get(‘lion’)) --- print(d[‘lion’]) ■ The keys( ) method print(d.keys( )) --- displays all the keys Dictionaries Functions
  • 7. ■ The items( ) method This method returns all the pairs as a sequence of (key,value) tuples. (in no particular order). L=d.items( ) print(L) --- [('dog' , 'friendly'),('lion' , 'wild'),('parrot' , 'funny')] ■ The values( ) method <dictionary>.values( ) --- returns all the values. Dictionaries Functions
  • 8. Dictionaries Functions ■ The update( ) method <dictionary>.update( <other-dictionary> ) <other-dictionary> will over-ride in <dictionary>. ● New Keys will be added. ● Existing key will be updated with new values. e.g. d = { 'dog' : 'friendly' , 'lion' : 'wild' , 'parrot' : 'funny' } d2= { 'dog' : pet' , 'lion' : 'wild' , tiger' : 'dangerous’ } d.update(d2) print(d) { 'dog' : pet' , 'lion' : 'wild' , 'parrot' : 'funny', ‘tiger’:’dangerous’ }
  • 9. Practice Time Q1. R={ 'Name' : 'Python', 'Age' : '20', 'Addr' : 'NJ' , 'Country' : 'USA' } id1=id(R) R2={ 'Name' : 'Python', 'Age' : '20', 'Addr' : 'NJ' , 'Country' : 'USA' } id2=id(R2) print(id1==id2) ( id( ) gives the address of the object ) Q2. D = { } D[ (1,2,4) ] =8 D[ (4,2,1) ] =10 D[ (1,2) ] =12 sum = 0 for k in D: sum+=D[k] print(sum) print(D)
  • 10. Practice Time 1. W.a.p. to verify whether the phone number is in the given format or not ( ex. 017-555-1212 is the correct format ) 2. Write a program that prints the longest word in a list. 3. Write a python program that creates a list storing first 9 terms of fibonacci series. 1, 1, 2, 3 ,5 ,8 …. 4. W.a.p. to make a list of all integers less than hundred which are multiples of 3 or 5. --- H.W.
  • 11. Practice Time 1. Write a function addDict(dict1, dict2) which computes the union of two dictionaries. If same key appears in both, pick either one. 2. Create a dictionary whose keys are month names and whose values are number of days in the corresponding months. a. Ask user to enter month name and number of days. b. Print out all of the keys in alphabetical order. c. Print out all of the months with 31 days. d. Print out the (key-value) pairs sorted by keys. e. Print out the (key-value) pairs sorted by values. Typical