Exercise

Finding all the data and the overlapping data between sets

Sets have several methods to combine, compare, and study them all based on mathematical set theory. The .union() method returns a set of all the elements found in the set you used the method on plus any sets passed as arguments to the method. You can also look for overlapping data in sets by using the .intersection() method on a set and passing another set as an argument. It will return an empty set if nothing matches.

Your job in this exercise is to find the union and intersection in the species from male and female penguins. For this purpose, two sets have been pre-loaded into your workspace: female_penguin_species and male_penguin_species.

Instructions

100 XP
  • Combine all the species in female_penguin_species and male_penguin_species by computing their union. Store the result as all_species.
  • Print the number of species in all_species. You can use the len() function to compute the number of species in all_species.
  • Find all the species that occur in both female_penguin_species and male_penguin_species by computing their intersection. Store the result as overlapping_species.
  • Print the number of species in overlapping_species.