Python: if possible answers in one line of code def name_sort(staff): ''' Question 2 You are given a list of Georgia Tech staff members- each with a first and last name separated by a space, and need to sort them alphabetically by last name for a directory. However, the person who provided you the list did not proofread the records and accidentally misspelled some of the names. You can identify which ones have typos just by looking at the first letter of the first name. - First, sort the list alphabetically by the last name. - Remove any members whose first name starts with "Q" or "X". - Return the resulting list. Args: staff (list) Returns: list >>> name_sort(['Damon Williams', 'Xngel Cabrera', 'George Burdell', 'Brett Key', 'David Joyner', 'Qon Lowe']) ['George Burdell', 'David Joyner', 'Brett Key', 'Damon Williams'] ''' # print(name_sort(['Damon Williams', 'Xngel Cabrera', 'George Burdell', 'Brett Key', 'David Joyner', 'Qon Lowe'])) # print(name_sort(['Melinda McDaniel', 'Buzz Yellowjacket', 'Josh Pastner', 'Nell Fortner', 'Michelle Collier'])) def gpa_manipulation(gpa_list): ''' Question 3 You are working in the registrars office and have a been given a list of the average gpas of each of the colleges at Georgia Tech: Scheller, College of Engineering, College of Design, College of Computing, Ivan Allen, College of Sciences. NOTE: GPA's are made up and in no particular order - First, one of the GPA's is None. Replace None with the 3.80. - Second, reverse the order of the list you are given. This should not be sorted simply reversed from the way you were given them - Third, change the type of the list to a tuple Args: gpa_list (list) Returns: tuple >>> gpa_manipulation([3.72, 3.25, 3.43, 2.99, None, 3.87]) (3.87, 3.80, 2.99, 3.43, 3.25, 3.72) '''
Python: if possible answers in one line of code
def name_sort(staff):
'''
Question 2
You are given a list of Georgia Tech staff members- each with a first and last name separated by a space,
and need to sort them alphabetically by last name for a directory. However, the person who provided you the list
did not proofread the records and accidentally misspelled some of the names. You can identify which ones
have typos just by looking at the first letter of the first name.
- First, sort the list alphabetically by the last name.
- Remove any members whose first name starts with "Q" or "X".
- Return the resulting list.
Args:
staff (list)
Returns:
list
>>> name_sort(['Damon Williams', 'Xngel Cabrera', 'George Burdell', 'Brett Key', 'David Joyner', 'Qon Lowe'])
['George Burdell', 'David Joyner', 'Brett Key', 'Damon Williams']
'''
# print(name_sort(['Damon Williams', 'Xngel Cabrera', 'George Burdell', 'Brett Key', 'David Joyner', 'Qon Lowe']))
# print(name_sort(['Melinda McDaniel', 'Buzz Yellowjacket', 'Josh Pastner', 'Nell Fortner', 'Michelle Collier']))
def gpa_manipulation(gpa_list):
'''
Question 3
You are working in the registrars office and have a been given a list of the average gpas of
each of the colleges at Georgia Tech: Scheller, College of Engineering, College of Design,
College of Computing, Ivan Allen, College of Sciences.
NOTE: GPA's are made up and in no particular order
- First, one of the GPA's is None. Replace None with
the 3.80.
- Second, reverse the order of the list you are given.
This should not be sorted simply reversed from the way
you were given them
- Third, change the type of the list to a tuple
Args:
gpa_list (list)
Returns:
tuple
>>> gpa_manipulation([3.72, 3.25, 3.43, 2.99, None, 3.87])
(3.87, 3.80, 2.99, 3.43, 3.25, 3.72)
'''
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 4 images