Ask Question
17 August, 09:37

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

+3
Answers (1)
  1. 17 August, 10:03
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers