Ask Question
23 February, 08:49

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.

+3
Answers (1)
  1. 23 February, 10:09
    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?
Find 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 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