Ivan 1c
unknown
python
4 years ago
2.4 kB
3
Indexable
ex = ''' 1.c) Let's pretend we have a new list representing an extended version of the l_schedule, such that it embeds information about the date, time and the duration (in hours) of the each lesson. We call the new list l_schedule_extended. Each element is represented as a tuple: ([HOURS],[DATE],[TIME],[TITLE]). For instance, the third lesson "Algorithms" will have the corresponding tuple: (2,"15/10/21","12:30-14:30","Algorithms"). Here we have the entire l_schedule_extended:''' l_schedule_extended = [(2,"11/10/21","09:30-11:30","Introduction to the course"), (2,"13/10/21","09:30-11:30","Introduction to Computational Thinking"), (2,"15/10/21","12:30-14:30","Algorithms"), (2,"18/10/21","09:30-11:30","Laboratory"), (2,"20/10/21","09:30-11:30","Computability"), (2,"22/10/21","12:30-14:30","Programming languages"), (2,"25/10/21","09:30-11:30","Organising information: ordered structures"), (2,"27/10/21","09:30-11:30","Laboratory"), (2,"29/10/21","12:30-14:30","Brute-force algorithms"), (2,"08/11/21","09:30-11:30","Laboratory"), (2,"10/11/21","09:30-11:30","Organising information: unordered structures"), (2,"15/11/21","09:30-11:30","Laboratory"), (2,"17/11/21","09:30-11:30","Recursion"), (2,"22/11/21","09:30-11:30","Laboratory"), (2,"24/11/21","09:30-11:30","Divide and conquer algorithms"), (2,"29/11/21","09:30-11:30","Laboratory"), (2,"01/12/21","09:30-11:30","Dynamic programming algorithms"), (2,"06/12/21","09:30-11:30","Organising information: trees"), (2,"13/12/21","09:30-11:30","Backtracking algorithms"), (2,"15/12/21","09:30-11:30","Organising information: graphs"), (2,"20/12/21","09:30-11:30","Greedy algorithms")] ''' Define a function max_lessons_hours() which takes l_schedule_extended and a number max_hours as parameters, and returns a list containing only the titles of all the lessons which could be attended with a maximum number of hours = max_hours, starting from the first lesson of the year.'''
Editor is loading...