Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
10327 views
ubuntu2004
Kernel: Python 3 (system-wide)

Exercise 15.1

Create a dictionary called mushrooms containing the data in the following table. Print it.

Scientific NameCommon Name
Fistulina hepaticaBeefsteak
Laetiporus sulphureusChicken-of-the-Woods
Flammulina velutipesEnoki
Hericium erinaceusLion’s Mane
mushrooms = {'Fistulina hepatica': 'Beefsteak', 'Laetiporus sulphureus': 'Chicken-of-the-Woods', 'Flammulina velutipes': 'Enoki', 'Hericium erinaceus': 'Lion’s Mane'} print(mushrooms)

Exercise 15.2

Add the following to mushrooms:
Pleurotus pulmonarius: Summer oyster
Pleurotus euosmos: Tarragon

mushrooms['Pleurotus pulmonarius'] = 'Summer oyster' mushrooms['Pleurotus euosmos'] = 'Tarragon' print(mushrooms)

Exercise 15.3

Print the common name for Laetiporus sulphureus.

print( mushrooms['Laetiporus sulphureus'] )

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.)

mushrooms['Laetiporus sulphureus'] = 'Sulphur Shelf' print( mushrooms )

Exercise 15.5

Test if the species Pholiota nameko is in mushrooms.

if 'Pholiota nameko' in mushrooms: print ( 'Pholiota nameko is in mushrooms' ) else: print ( 'Pholiota nameko is not in mushrooms' )

Exercise 15.6

Create an empty dictionary called books.

books = {} print( books )

Exercise 15.7

Add the following two books to your dictionary books:

Book titleAuthour
The chimpanzees of GombeJane Goodall
The blind watchmakerRichard Dawkins
books['The chimpanzees of Gombe'] = 'Jane Goodall' books['The blind watchmaker'] = 'Richard Dawkins' print(books)