Ask Question
23 October, 09:16

The following program includes fictional sets of the top 10 male and female baby names for the current year. Write a program that creates: A set all_names that contains all of the top 10 male and all of the top 10 female names. A set neutral_names that contains only names found in both male_names and female_names. A set specific_names that contains only gender specific names. Sample output for all_names: {'Michael', 'Henry', 'Jayden', 'Bailey', 'Lucas', 'Chuck', 'Aiden', 'Khloe', 'Elizabeth', 'Maria', 'Veronica', 'Meghan', 'John', 'Samuel', 'Britney', 'Charlie', 'Kim'} NOTE: Because sets are unordered, they are printed using the sorted () function here for comparison

+5
Answers (1)
  1. 23 October, 10:43
    0
    Following are the program in the Python Programming Language.

    male_names = {'kay', 'Dev', 'Sam', 'Karan', 'Broly', 'Samuel', 'Jayd', 'Lucifer', 'Amenadiel', 'Anmol'}

    female_names = {'Kally', 'Megha', 'Lucy', 'Shally', 'Bailey', 'Jayd', 'Anmol', 'Beth', 'Veronica', 'Sam'}

    #initialize the union from male_names and female_names

    all_names = male_names. union (female_names)

    #Initialize the similar names from male_names and female_names

    neutral_names = male_names. intersection (female_names)

    #initialize the symmetric_difference from male_names and female_names

    specific_names = male_names. symmetric_difference (female_names)

    #print the results

    print (sorted (all_names))

    print (sorted (neutral_names))

    print (sorted (specific_names))

    Output:

    ['Amenadiel', 'Anmol', 'Bailey', 'Beth', 'Broly', 'Dev', 'Jayd', 'Kally', 'Karan', 'Lucifer', 'Lucy', 'Megha', 'Sam', 'Samuel', 'Shally', 'Veronica', 'kay']

    ['Anmol', 'Jayd', 'Sam']

    ['Amenadiel', 'Bailey', 'Beth', 'Broly', 'Dev', 'Kally', 'Karan', 'Lucifer', 'Lucy', 'Megha', 'Samuel', 'Shally', 'Veronica','kay']

    Explanation:

    The following are the description of the program.

    In the above program, firstly we set two list data type variables 'male_names' and 'female_names' and initialize the male and female names in those variables. Then, we set three variables in which we store union, intersection, and symmetric differences and finally print these three variables in a sorted manner.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “The following program includes fictional sets of the top 10 male and female baby names for the current year. Write a program that creates: ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers