ubuntu2004
Kernel: Python 3 (system-wide)
Exercise 15.1
Create a dictionary called mushrooms
containing the data in the following table. Print it.
Scientific Name | Common Name |
---|---|
Fistulina hepatica | Beefsteak |
Laetiporus sulphureus | Chicken-of-the-Woods |
Flammulina velutipes | Enoki |
Hericium erinaceus | Lion’s Mane |
In [4]:
Out[4]:
{'Fistulina hepatica': 'Beefsteak',
'Laetiporus sulphureus': 'Chicken-of-the-Woods',
'Flammulina velutipes': 'Enoki',
'Hericium erinaceus': "Lion's Mane"}
Exercise 15.2
Add the following items to mushrooms
:
Pleurotus pulmonarius: Summer oyster
Pleurotus euosmos: Tarragon
In [7]:
Out[7]:
{'Fistulina hepatica': 'Beefsteak',
'Laetiporus sulphureus': 'Chicken-of-the-Woods',
'Flammulina velutipes': 'Enoki',
'Hericium erinaceus': "Lion's Mane",
'Pleurotus pulmonarius': 'Summer oyster',
'Pleurotus euosmos': 'Tarragon'}
Exercise 15.3
Print the common name for Laetiporus sulphureus.
In [8]:
Out[8]:
'Chicken-of-the-Woods'
Exercise 15.4
Replace the common name for Laetiporus sulphureus with Sulphur Shelf (this is another common name for this species which forms striking golden-yellow shelf-like fungal structures on tree trunks and branches.)
In [9]:
Out[9]:
{'Fistulina hepatica': 'Beefsteak',
'Laetiporus sulphureus': 'Sulphur Shelf',
'Flammulina velutipes': 'Enoki',
'Hericium erinaceus': "Lion's Mane",
'Pleurotus pulmonarius': 'Summer oyster',
'Pleurotus euosmos': 'Tarragon'}
Exercise 15.5
Test if the species Pholiota nameko is in mushrooms
.
In [10]:
Out[10]:
no
Exercise 15.6
Create an empty dictionary called books
.
In [11]:
Exercise 15.7
Add the following two books to your dictionary books
:
Book title | Authour |
---|---|
The chimpanzees of Gombe | Jane Goodall |
The blind watchmaker | Richard Dawkins |
In [14]:
Out[14]:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-14-79fa85f20bef> in <module>
2 books['The blind watchmaker'] = 'Richard Dawkins'
3
----> 4 print(books[1])
KeyError: 1