View the step-by-step solution to:


please see below

this is practice questions, not to be submitted for marks. this course has a

100% finalScreen Shot 2019-10-01 at 10.44.22 AM.png

Screen Shot 2019-10-01 at 10.44.22 AM.png

3. (30) Dictionary of dictionaries can be used as a simple database. For instance, dictionary in Figure 2 can be
used for tracking information about scientists.
db_dic = {
'jgoodall '
: { ' surname'
'Goodall' ,
"Jane' ,
: 1934
: None,
'primate researcher' ,
' author'
'rfranklin' : {' surname'
['In the Shadow of Man' , 'The Chimpanzees of Gombe' ]},
'Rosalind' ,
contributed to discovery of DNA' },
: { surname
Carson' ,
'Rachel' ,
'raised awareness of effects of DDT' ,
: [ 'Silent Spring' ] }
Figure 2: A dictionary of dictionary example
Assume that the data is provided as a text file (see dic_db scientists.txt). First, you need to read and save
the data as a dictionary of dictionaries as shown in Figure 2. Note that first value in each line is a key, and
the rest is the value. If there are multiple values to be stored, these values are separated by comma (as in the
case for author key of jgoodall). Next, answer the following questions:
(a) Write a python function called db headings that returns the set of keys used in any of the inner diction
naries. In the example in Figure 2, the function should return
set ('author , forename' ,' surname' ;' notes',' born' ;' died')
(b) Write another function called db_consistent that takes a dictionary of dictionaries in the format de-
scribed in the previous question and returns True if and only if every one of the inner dictionaries has
exactly the same keys. (This function would return False for the previous example, since Rosalind
Franklin's entry does not contain the 'author' key.)

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes