Complete the function read_student_information(student_file: str) ? list as follows: - the function takes a str as input, the name of a. csv file to read lines from - the function returns a list, where each element is itself a list as follows: - the first element (index position 0) is a str, representing a students name - the remaining elements in the list are all list, each with 2 elements as follows: - in index position 0 , a str, the name of a subject - in index position 1 , an int, the students score on that subject The format of the student_file is lines, in comma separated format (i.e. the file has a 'csv' extension). For each line, the items in each field are as follows: Note that: - for each student there are 4 subjects and corresponding score (e.g. subject 1 is in field 2 and the corresponding score for that subject is in field 3 ). - the Field headings are not included in the student information file (see the supplied file student_info.csvas an example) For example, you are supplied with the file student_info.csv (see below), which contains the following lines: Julie_Porteous,art, 55, textiles, 97, photography, 96, literature, 94 Geela_Chi,literature, 95, latin, 97, algorithmics, 99, maths, 96 Axel_Ahmer,maths, 100,french, 90, psychology, 83, iterature, 72
Complete the function sort_student_list(student_list: list) ? list: as follows: - the function takes as input a list, where each element is itself a list, with the same format as returned from the function read_student_information in Task 1 above. - the function returns a version of the 1 ist, in ascending sorted alphabetic order, using student_name (i.e. the string in index 0 of each list element). For example for the following student_list: student_list =[[ Julie_Porteous', ['art', 55], ['textiles', 97], ['photography', 96], ['literature', 94]], ['Geela_Chi', ['literature', 95], ['latin', 97], ['algorithmics', 99], ['maths', 96]], ['Axel_Ahmer',['maths',100], ['french', 90], ['psychology', 83], ['literature', 72]]] the function call sort_student_list(test_student_list) will return: [['Axel Ahmer', ['maths', 100], ['french', 90], ['psychology', 83], ['literature', 72]], ['Geela Chi', ['literature', 95], ['latin', 97], ['algorithmics', 99], ['art', 85]], ['Julie Porteous', ['art', 55], ['textiles', 97], ['photography', 96], ['literature', 94]]] Note: the order of each element for each student is unchanged when the list is sorted. For example, the list for this student ['Julie Porteous', ['art', 55], ['textiles', 97], ['photography', 96], ['literature', 94]] is unchanged when the overall student list is sorted (as shown above).
Complete the function highest_scoring_student(student_list: list, subject) ? tuple[str, int]. The function: - takes as input - a list of student information with the same format as the list returned in Task 1 defined above - a str, the name of the subject to find the highest score for ( you can assume your code will be tested with only a single highest score) - if the subject appears in the list of student information, the function returns a tuple [str, int ], where: - the str is the name of the highest scoring student - the int is the score the student received for the subject - if the subject is not found in the list then: - raise a ValueError exception with the str 'Error: subject not found' as its argument For example for the following list and function call: student_list =[ ['Julie Porteous', ['art', 55], ['textiles', 97], ['photography', 96], ['literature', 94]], ['Geela Chi', ['literature', 95], ['latin', 97], ['algorithmics', 99], ['art', 85]], ['Axel Ahmer', ['maths', 100], ['french', 90], ['psychology', 83], ['literature', 72]]] subject = 'literature' highest_scoring_student(student_list,_subject) will return:
\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \# Task 1: Complete this function \# read_student_information (student_file: str) ? list: \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# def read_student information (student file): \# \# Your code goes here \# return [None] ]n? Fix this \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \# Task 2: Complete this function \# sort_student_list(test_student_list: list) ? list \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# def sort_student_list(student_list): \# \# Your code goes here \# return [None] ]w? Fix this \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \# Task 3: Complete this function \# highest_scoring_student(student_list: list, subject:str) - tuple[str, int]: \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# def highest_scoring_student(student_list, subject): \#
\# highest_scoring_student(student_list: List, subject:str) ? tuple[str, int]: \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# def highest_scoring_student(student_list, subject): # \# Your code goes here # return 'None', -1 \# Fix this \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \# The following code is provided as a starting point for development and testing \# Please modify the code below as you develop your program. \# \# NOTE: you can submit WITH or WITHOUT the following main \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# if \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \# Test code for Task 1 \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# print('Task 1:') filename = 'student_info.csv' print(f'Student information from file: \{read_student_information(filename) }? ) \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \# Test code for Task 2