Function Name: class Trip() Parameters: friendList (list) Returns: nameList (list) Description: Your TAs have decided to

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Function Name: class Trip() Parameters: friendList (list) Returns: nameList (list) Description: Your TAs have decided to

Post by answerhappygod »

Function Name Class Trip Parameters Friendlist List Returns Namelist List Description Your Tas Have Decided To 1
Function Name Class Trip Parameters Friendlist List Returns Namelist List Description Your Tas Have Decided To 1 (52.88 KiB) Viewed 29 times
please solve it as python
Function Name: class Trip() Parameters: friendList (list) Returns: nameList (list) Description: Your TAs have decided to take the whole CS 1301 class on a field trip and you can bring your friends! But they dont have the money to pay for everyone. You are provided with a list containing sublists. Each sublist includes the name of your friend (str), their age (int), and how much money they are bringing (float ). The elements of the sublists are in no particular order, and some friends may be repeated, appearing in multiple sublists. From this jumbled list of lists, you wish to create a list of just your friends' names. Write a function that takes in a list of lists as de- scribed, and returns a list of the names of your friends that are coming on the trip, with no names repeated, and sorted in alphabetical order. Hint: The .sort() method or sorted() function will be useful here. >>> class Trip ([["Kathleen", 26, 40.0], [19, "Jada", 52.0], ["Kathleen", 26, 40.0], ["Samuel", 22, 36.0], [22, 68.0, "Annie"], [21, 70.0, "Arvin"], [21, "Cooper", 92.0], ["Leana", 22, 36.0], [21, 92.0, "Cooper"]]) ['Annie', 'Arvin', 'Cooper', 'Jada', 'Kathleen', 'Leana', 'Samuel'] >>> classTrip ([[22, "Rocky", 103.0], ["Felix", 19.0, 20], ["Elizabeth", 11.0, 65], [15.0, 20, "Astrid"], [23, "Elizabeth", 88.0], [72.0, 21, "Felix"]]) ['Astrid', 'Elizabeth', 'Felix', 'Rocky']
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply