def setofNames (profiles, location): Specific Restrictions (in addition to the general restrictions above): You are only allowed set(), .items(), .values(), keys(), .add(), .get() o You should only use sets and dictionaries Description: profiles is a dictionary keeping track of the dating app members. The dictionary key is a profile ID, and the value is a list containing: member name, phone number and location. location is a string containing some location search value. This function returns a set containing the member's names who live in the search value location. Parameters: profiles is a dictionary of variable size that contains profile ID (string) as key and the member's name (string), phone number (string) and location (string) (in list format) as value. location is a string. Return value: a set containing the names of the members (string). Note that this function does return something! Assumptions: All input values are valid. The order of the list values in the dictionary is: member name first, followed by phone number and then location. Examples: profiles={ "B111":["Anahi Saunders", "502-223-221", "Fair"], "8222":["Thaddeus Huff", "501-121-1123", "Washington "], "8333": ["Deven Holden", "123-323-3463", "Vien"], "8444": ["Cale Day", "501-56-5321","Cha"], "B555":["Kenley Hartman", "231-331-34", "Alex"], "B666":["Giovanni Ruiz", "123-258-1251", "Alex"], "8777":["Kamari Knox", "224-127-2762", "Washington "], "8888":["Kael Barr", 321-124-3312", "Washington"], "B999":["Catalina Colon", "711-256-8456", "Fair"], "B010":["Jasiah Fritz","513-212-1252", "Fair"] } setofNames(profiles, "Fair") setofNames/profiles, "Washington") setofNames/profiles, "Cha") {"'Catalina Colon", "Anahi Saunders", "Jasiah Fritz"} {"Kael Barr", "Thaddeus Huff", "Kamari Knox"} {'Cale Day'} Explanation: We first create a new set, as we loop through the dictionary looking for all location matches to the passed-in search value; every time there is a match found, we take the name from that dictionary value and add it to the set. When we have looked through the entire dictionary, we return the populated set.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

 

 

Background
Loop statements allow us to run the same block of code repeatedly, with the chance to use
different values for variables each time as the accumulated effects pile up. Lists are sequences
that can be inspected value-by-value and modified at will. In this PROGRAMMING we will use
loops to perform calculations or adjustments on lists and multidimensional lists. We will also
explore other sequences such as sets and dictionaries.
General Restrictions
•
You are not allowed to import anything
•
You are not allowed to use slicing
•
You are not allowed to use any string methods
• Please pay attention to specific restrictions written in for each individual function below
• Don't forget to comment the code
• No hard coding!
Transcribed Image Text:Background Loop statements allow us to run the same block of code repeatedly, with the chance to use different values for variables each time as the accumulated effects pile up. Lists are sequences that can be inspected value-by-value and modified at will. In this PROGRAMMING we will use loops to perform calculations or adjustments on lists and multidimensional lists. We will also explore other sequences such as sets and dictionaries. General Restrictions • You are not allowed to import anything • You are not allowed to use slicing • You are not allowed to use any string methods • Please pay attention to specific restrictions written in for each individual function below • Don't forget to comment the code • No hard coding!
def setof Names (profiles, location):
Specific Restrictions (in addition to the general restrictions above):
You are only allowed set(), .items(), .values(), .keys(), .add(), .get()
o You should only use sets and dictionaries
Description: profiles is a dictionary keeping track of the dating app members. The dictionary key
is a profile ID, and the value is a list containing: member name, phone number and location.
location is a string containing some location search value. This function returns a set containing
the member's names who live in the search value location.
Parameters: profiles is a dictionary of variable size that contains profile ID (string) as key
and the member's name (string), phone number (string) and location (string) (in list format) as
value. location is a string.
Return value: a set containing the names of the members (string).
Note that this function does return something!
Assumptions: All input values are valid. The order of the list values in the dictionary is: member
name first, followed by phone number and then location.
Examples:
profiles = {
"B111": ["Anahi Saunders", "502-223-221", "Fair"],
"B222": ["Thaddeus Huff", "501-121-1123", "Washington "],
"B333": ["Deven Holden", "123-323-3463", "Vien"],
"B444":["Cale Day", "501-56-5321", "Cha"],
"B555":["Kenley Hartman", "231-331-34", "Alex"],
"B666":["Giovanni Ruiz", "123-258-1251", "Alex"],
"B777":["Kamari Knox", "224-127-2762", "Washington "],
"B888":["Kael Barr", 321-124-3312", "Washington "],
"B999":["Catalina Colon", "711-256-8456", "Fair"],
"B010":["Jasiah Fritz", "513-212-1252", "Fair"]
}
setofNames(profiles, "Fair")
setofNames(profiles, "Washington")
setofNames(profiles, "Cha")
{'Catalina Colon', 'Anahi Saunders', 'Jasiah Fritz"}
{"Kael Barr', 'Thaddeus Huff', 'Kamari Knox"}
{'Cale Day'}
Explanation:
We first create a new set; as we loop through the dictionary looking for all location matches to the passed-in search value; every time
there is a match found, we take the name from that dictionary value and add it to the set. When we have looked through the entire
dictionary, we return the populated set.
Transcribed Image Text:def setof Names (profiles, location): Specific Restrictions (in addition to the general restrictions above): You are only allowed set(), .items(), .values(), .keys(), .add(), .get() o You should only use sets and dictionaries Description: profiles is a dictionary keeping track of the dating app members. The dictionary key is a profile ID, and the value is a list containing: member name, phone number and location. location is a string containing some location search value. This function returns a set containing the member's names who live in the search value location. Parameters: profiles is a dictionary of variable size that contains profile ID (string) as key and the member's name (string), phone number (string) and location (string) (in list format) as value. location is a string. Return value: a set containing the names of the members (string). Note that this function does return something! Assumptions: All input values are valid. The order of the list values in the dictionary is: member name first, followed by phone number and then location. Examples: profiles = { "B111": ["Anahi Saunders", "502-223-221", "Fair"], "B222": ["Thaddeus Huff", "501-121-1123", "Washington "], "B333": ["Deven Holden", "123-323-3463", "Vien"], "B444":["Cale Day", "501-56-5321", "Cha"], "B555":["Kenley Hartman", "231-331-34", "Alex"], "B666":["Giovanni Ruiz", "123-258-1251", "Alex"], "B777":["Kamari Knox", "224-127-2762", "Washington "], "B888":["Kael Barr", 321-124-3312", "Washington "], "B999":["Catalina Colon", "711-256-8456", "Fair"], "B010":["Jasiah Fritz", "513-212-1252", "Fair"] } setofNames(profiles, "Fair") setofNames(profiles, "Washington") setofNames(profiles, "Cha") {'Catalina Colon', 'Anahi Saunders', 'Jasiah Fritz"} {"Kael Barr', 'Thaddeus Huff', 'Kamari Knox"} {'Cale Day'} Explanation: We first create a new set; as we loop through the dictionary looking for all location matches to the passed-in search value; every time there is a match found, we take the name from that dictionary value and add it to the set. When we have looked through the entire dictionary, we return the populated set.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY