Question: Function Specifications You cannot use list comprehensions to solve any of these problems. If you don't know what these are, don't worry about it, you
Function Specifications You cannot use list comprehensions to solve any of these problems. If you don't know what these are, don't worry about it, you don't need to know about them for this course. 1. Design the function swap that takes a list of values as an argument and two additional arguments that represent positions in the list. The function should swap the values at specified positions in the list, The function should assume the positions given are valid positions within the list. Examples: If the function is called with the list [12, 4, 3,-2) and positions 1 and 3. the function will update the list to [12, -2,3,4] Notice: nothing is retumed! 2. Design the function index_of_smallest that takes a list of values as an argument and finds and returns the position of the smallest value. If there are duplicate entries of the smallest value, the function should return the index of the first occurrence. If the list is empty, the function should return - I. Your function should assume the values in the list are comparable using the relational operators (,=....). Examples: If the function is called with the list [12, 6, 2, 22, -14, 10, -2] the function should return 4 If the function is called with the list ['a', 'b', 'd', 'e', 'a') the function should return 0 3. Design a type alias to represent the following flight information as a tuple: the departure city, the arrival city and the duration of the flight The type alias should assume the duration is in hours and it is more than 0 hours Example: ("Victoria', 'Mexico City', 5.5) 4. Design the function total_duration that takes a list of flight information tuples (as described in specification 3). The function should calculate and return the total duration of all flights in the given list. Example: If the function is called with the list [('Victoria', 'Mexico City', 5.5), ('Vancouver', 'Toronto', 4) the function should return 9.5 5. Design the function get_destinations from that takes a list of flight information tuples (as described in specification 3) and a departure city. The function should return a list of all the unique destinations that are flown to from the given departure city
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
