Consider the Student class in the provided student.py file. Each student has a name, an id and a list of courses taken. A course is represented as a list with three items to indicate the course name, semester taken and grade. For example, [‘comp1008’, ‘S24’, 76.3] represents this course with a final grade of 76.3. Complete all the functions in the provided a4.py file.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Consider the Student class in the provided student.py file. Each student has a name, an id and
a list of courses taken. A course is represented as a list with three items to indicate the course
name, semester taken and grade. For example, [‘comp1008’, ‘S24’, 76.3] represents this course
with a final grade of 76.3.

Complete all the functions in the provided a4.py file.

a4.py
a4.py > ...
1 import student
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
GARIZAHANGGANG
19
20
21
22
23
24
25
26
27
28
29
31
32
33
34
35
36
X
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def ave(student):
'''Returns the average of all courses that the input student has taken.
If the student has not taken any courses return 0.
pass
def sortByName(student_list):
***Sorts the input list of students alphabetically by their names.
The function modifies the input list and returns nothing.
Note: case does not matter.
30 def find(student_list, course_names, semesters, grade_range):
***Returns a list of students from the input list that
pass
def sortByAve(student_list):
'Returns a new list that is the sorted version of the input list.
The new list will be sorted by student course averages (highest to lowest).
The input list should not be modified in any way.
pass
def findByClass(student_list, course_name):
***Returns a list students that are in the input list that have
taken the course specified by course_name.
The input list should not be modified.
Note: case does not matter.
pass
have taken a course in the list course_names during a semester
in the list semester with a grade in the grade_range.
The grade_range is a list [lower_bound,upper_bound] of size 2. It has
the lower and upper bounds for the grade range (inclusive). The grade_range
[0,100] is any grade. The grade_range [50,100] is any passing grade.
Note: case does not matter.
def example():
s1 = student.make('cat', 12, [('comp1005', 'S23', 87.3), ('music1001', 'S23', 83.2) ])
s2 = student.make('owl', 3, [('comp1005', 'S23', 99.1),('phys1001', 'S23', 98.3) ])
s3 = student.make('dog', 17, [('comp1005', 'S23', 57.3),('music1001', 'S23', 99.1), ('math2210', 'S23', 76.1), ])
students = [s1, s2,s3]
print (students)
# calling find (students, ['comp1005'], ['S23'], [80,100]) should return the list with s1 and s2 in it.
# calling find (students, ['music1001'], ['S23'], [90,100]) should return the list with s3 in it.
# calling find(students, ['comp1005'], ['F22'], [0,100]) should return an empty list
if name ==
example()
main':
Transcribed Image Text:a4.py a4.py > ... 1 import student 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 GARIZAHANGGANG 19 20 21 22 23 24 25 26 27 28 29 31 32 33 34 35 36 X 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 def ave(student): '''Returns the average of all courses that the input student has taken. If the student has not taken any courses return 0. pass def sortByName(student_list): ***Sorts the input list of students alphabetically by their names. The function modifies the input list and returns nothing. Note: case does not matter. 30 def find(student_list, course_names, semesters, grade_range): ***Returns a list of students from the input list that pass def sortByAve(student_list): 'Returns a new list that is the sorted version of the input list. The new list will be sorted by student course averages (highest to lowest). The input list should not be modified in any way. pass def findByClass(student_list, course_name): ***Returns a list students that are in the input list that have taken the course specified by course_name. The input list should not be modified. Note: case does not matter. pass have taken a course in the list course_names during a semester in the list semester with a grade in the grade_range. The grade_range is a list [lower_bound,upper_bound] of size 2. It has the lower and upper bounds for the grade range (inclusive). The grade_range [0,100] is any grade. The grade_range [50,100] is any passing grade. Note: case does not matter. def example(): s1 = student.make('cat', 12, [('comp1005', 'S23', 87.3), ('music1001', 'S23', 83.2) ]) s2 = student.make('owl', 3, [('comp1005', 'S23', 99.1),('phys1001', 'S23', 98.3) ]) s3 = student.make('dog', 17, [('comp1005', 'S23', 57.3),('music1001', 'S23', 99.1), ('math2210', 'S23', 76.1), ]) students = [s1, s2,s3] print (students) # calling find (students, ['comp1005'], ['S23'], [80,100]) should return the list with s1 and s2 in it. # calling find (students, ['music1001'], ['S23'], [90,100]) should return the list with s3 in it. # calling find(students, ['comp1005'], ['F22'], [0,100]) should return an empty list if name == example() main':
student.py X
student.py > ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import copy
# student class
class Student:
'''Each student will have a name, id and courses field''
def_str_(self):
return f'{self.name}[{self.id}]:{len(self.courses)}'
def_repr_(self):
return f'{self.name}:{self.id}:{self.courses}'
def make (name, id, courses
s = Student ()
s.name = name
s.id
id
=
=
[]):
s.courses = copy.deepcopy (courses)
return s
Transcribed Image Text:student.py X student.py > ... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 import copy # student class class Student: '''Each student will have a name, id and courses field'' def_str_(self): return f'{self.name}[{self.id}]:{len(self.courses)}' def_repr_(self): return f'{self.name}:{self.id}:{self.courses}' def make (name, id, courses s = Student () s.name = name s.id id = = []): s.courses = copy.deepcopy (courses) return s
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education