Ask Question
18 June, 23:48

The top 3 most popular male names of 2017 are Oliver, Declan, and Henry according to babynames. Write a program that modifies the male_names set by removing a name and adding a different name. Sample output with inputs: 'Oliver' 'Atlas' { 'Atlas', 'Declan', 'Henry' } NOTE: Because sets are unordered, the order in which the names in male_names appear may differ from above.

+1
Answers (1)
  1. 19 June, 00:02
    0
    The code is given below in Python with appropriate comments

    Explanation:

    # convert list to set

    male_names = set (['Oliver','Declan','Henry'])

    # get remove and add name from user

    remove_name = input ("Enter remove name: ")

    add_name = input ("Enter add name: ")

    # remove name from set

    male_names. remove (remove_name)

    # add new name ij set

    male_names. add (add_name)

    # sort the set

    a = sorted (male_names)

    # print the set

    print (a)
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “The top 3 most popular male names of 2017 are Oliver, Declan, and Henry according to babynames. Write a program that modifies the ...” in 📙 Engineering if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers