Answer:
Answer code is given below and explained step by step with comments. Output is given at the end of code as well as attached as an image. Happy Learning!
Step-by-step explanation:
Code:
Male_Names ={'Michael','Henry','Jayden','Bailey','Lucas','Chuck','Aiden',' John','Samuel','Charlie'} # array to store Male Names
Female_Names= {'Khloe','Elizabeth','Maria','Veronica','Meghan','Britney', 'Kim','Bailey', 'Jayden', 'Aiden'} # array to store Female Names
All_Names = Male_Names.union(Female_Names) # the union will return all the names found in Male_Names + Female_Names and if there are any duplicate names then they will appear only once
Neutral_Names = Male_Names.intersection(Female_Names) # the intersection will return only those names which are common in both Male_Names and Female_Names hence they will be neutral names
Specific_Names = Male_Names.symmetric_difference(Female_Names) # the symmetric_difference will return only those names which are not common in Male_Names and Female_Names hence they will be Male Names and Female Names
print(All_Names) # to print all the names
print(Neutral_Names) # to print neutral names
print(Specific_Names) # to print specific names
print(sorted(All_Names)) # to print all the names in ascending order
print(sorted(Neutral_Names)) # to print neutral names in ascending order
print(sorted(Specific_Names)) # to print specific names in ascending order
Notice that male and female names are 10 each
In both of these lists 3 names are common
so there are 7 unique male names and 7 unique female names
All_Names must return 7 unique male names, 7 unique females names and 3 common names = 7+7+3= 17 names
Neutral_Names must return 3 common names
Specific_Names must return 7 male males and 7 female names
7+7= 14 names
OUTPUT:
Unsorted:
{'Henry', 'Bailey', 'Elizabeth', 'John', 'Chuck', 'Britney', 'Lucas', 'Khloe', 'Charlie', 'Aiden', 'Jayden', 'Kim', 'Samuel', 'Maria', 'Michael', 'Veronica', 'Meghan'}
{'Bailey', 'Jayden', 'Aiden'}
{'Henry', 'Elizabeth', 'John', 'Chuck', 'Britney', 'Lucas', 'Khloe', 'Kim', 'Maria', 'Veronica', 'Charlie', 'Samuel', 'Michael', 'Meghan'}
Sorted:
{'Aiden', 'Bailey', 'Britney', 'Charlie', 'Chuck', 'Elizabeth', 'Henry', 'Jayden', 'John', 'Khloe', 'Kim', 'Lucas', 'Maria', 'Meghan', 'Michael', 'Samuel', 'Veronica'}
{'Aiden', 'Bailey', 'Jayden'}
{'Britney', 'Charlie', 'Chuck', 'Elizabeth', 'Henry', 'John', 'Khloe', 'Kim', 'Lucas', 'Maria', 'Meghan', 'Michael', 'Samuel', 'Veronica'}