Question: A simple python programme for questions 6,7,8 1. Design the function multiply_by that takes a list as an argument and an additional integer argument as



A simple python programme for questions 6,7,8
1. Design the function multiply_by that takes a list as an argument and an additional integer argument as a multiplier. The function should multiply every element in the given list by the given multiplier. This function should assume that the given list will contain elements that can be multiplied by an integer and that the multiplier will not be negative. 2. Design the function double_odd that takes a list of integer. The function should double all of the odd-valued elements in the list. 3. Design a type alias to represent the following Date information as a tuple: the year, the month and the day (in exactly this order) The type alias should assume: - the year is no earlier than the first year in the Gregorian calendar (1582) - the month is a valid month in the Gregorian calendar (our Calendar) and the initial letter is capitalized and no abbreviations are used - the day is a valid day given the values of the year and month Example: (1996, 'June', 15) Note: The Gregorian Calendar was first adopted in 1582 and is in use worldwide. 4. Design the function get_zodiac signs that takes a list of date information tuples (as described in specification 3). The function should return a list of the corresponding zodiac signs for the dates in the given list Example: If the function is called with the list: [(1990, 'September', 15), (1829, December', 28), (1845, 'August', 27)] the function should return the list ['Virgo', Capricorn', 'Virgo'] The order of the values in the returned list must correspond to the order of the date information in the given list Grading will take into account your implementation/use of a helper function to reduce the complexity of this function. Consider looking back to Lab 2 to see if there is a function you can modify to help you solve this problem. 5. Design the function create_lodates that takes a list month names, a list of days as whole numbers and a list of years as whole numbers. The function should create and return a list of of date information tuples (as described in specification 3) constructed using the values in the given lists. Example: If the function is called with the following 3 lists: ['January', 'June'), [20, 10] and [1987, 2020) it should return the list: ((1987, January', 20), (2020, June', 10)] The order of the dates in the returned list must correspond to the order of the values in the given lists. The function should assume the given lists are all of equal length and that the values in the given lists combine to make valid dates. 6. Design the function contains_month that takes a list of date information tuples (as described in specification 3) and an additional argument the specifies a valid month. The function should return True if any of the dates in the given list are in the given month, and False otherwise. The function should assume the second argument is a valid month in the Gregorian calendar (our Calendar) and the initial letter is capitalized and no abbreviations are used. 7. Copy the type alias for flight information that you designed in Lab 7. Using your flight information and date type aliases (as described in specification 3), you are now going to design a type alias to represent flight schedule information as a tuple with exactly these 2 things: the flight information, a list of dates that flight departs on Example: flight_van_tor = ('Vancouver', 'Toronto', 4) dates_van_tor = f(2020, October, 1), (2020, October', 12), (2020, 'November, 12), (2020, December, 1)) flight_schedule_van_tor = (flight_van_tor, dates_van_tor) 8. Design the function get_flights_in_month that takes a list of flight schedule information tuples (as described in specification 7) and an additional argument that specifies a valid month. The function should return a list of just the flight information (as described in Lab 7) of the flights in the in the given list that are scheduled in the given month. The function should assume the second argument is a valid month in the Gregorian calendar (our Calendar) and the initial letter is capitalized and no abbreviations are used. Example: flight_van_tor = ('Vancouver', Toronto', 4) dates_van_tor = |(2020, October', 1).(2020, October', 12), (2020, 'November', 12), (2020, December', 1)] flight_schedule_van_tor = (flight_van_tor, dates_van_tor) flight_lon_mos = ('London', "Moscow, 6) dates_lon_mos = [(2020, October', 21), (2020, December', 14) flight_schedule_lon_mos = (flight_lon_mos, dates_lon_mos) flight_sea_bang = ('Seattle', 'Bangkok', 6) dates_sea_bang = [(2020, October', 18), (2020, "November', 6)] flight_schedule_sea_bang = (flight_sea_bang, dates_sea_bang) list_of_flight_schedules = [flight_schedule_van_tor, flight_schedule_lon_mos, flight_schedule_sea_bang) The function call get_flights_in_month(list_of_flight_schedules, 'October") returns: [('Vancouver' , 'Toronto', 4), ('London", "Moscow', 6), ('Seattle', 'Bangkok', 6)] since all three flights are scheduled to fly in October. The function call get_flights_in_month(list_of_flight_schedules, "November) returns: [('Vancouver', 'Toronto', 4), ('Seattle', 'Bangkok', 6)] since there are no flights from London to Moscow in November
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
