The top 3 most popular male names of 2017 are oliver, Declan, and Henry according to babynames.com. 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.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter8: Advanced Data Handling Concepts
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question
The top 3 most popular male names of 2017 are oliver, Declan, and Henry according to babynames.com.
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.
367036.2214230.qx3zqy7
1 male_names
2 name_to_remove =
3 name_to_add
{ 'Oliver', 'Declan', 'Henry' }
input ()
input ()
4
...
...
5
Your solution goes here
6.
7 print (male_names)
Transcribed Image Text:The top 3 most popular male names of 2017 are oliver, Declan, and Henry according to babynames.com. 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. 367036.2214230.qx3zqy7 1 male_names 2 name_to_remove = 3 name_to_add { 'Oliver', 'Declan', 'Henry' } input () input () 4 ... ... 5 Your solution goes here 6. 7 print (male_names)
Expert Solution
Step 1

Task :- Write a python program to add and remove names from given set.

 

Python program :- 

 

male_names = {'Oliver', 'Declan', 'Henry'}
name_to_remove = input()
name_to_add = input()

# first remove input name from the set
male_names.remove(name_to_remove)
# Now add name to the set
male_names.add(name_to_add)

#print modified set
print(male_names)

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning