To have an overview of different populations of various species, we will collect this data in a dictionary.
Write a Python script that includes the following functionalities.
Write a function Add_population
that adds a new species and population name to a dictionary called populations. The function should have the following input parameters:
· populations: a dictionary where the population data is stored. This has the species as the key and a set of habitats where this species occurs as the value.
· speciesName: the name of the species (string)
· populationName: the name of the population (string)
If the species already exists in the dictionary populations, add the population name to the set of population names for that species. If the species is not yet in the dictionary, add this species along with a set containing the population name as a key pair.
delete_population
that removes a species and/or population name from the dictionary populations. The function should have the following input parameters:· populations: a dictionary where the population data is stored. This has the species as the key and a set of habitats where this species occurs as the value.
· speciesName: the name of the species (string)
· populationName: the name of the population (string), which is an optional parameter.
If only the species is provided, that species and the entire set of population names will be removed from the dictionary. If both a species and a population name are provided, only that population name will be removed from the set. If the species does not exist in populations or if the provided population name is not in the set of population names for that species, the function should display an error message.