Question: (Student.py) class Student: def __init__(self, name, student_id): self.__name = name self.__id = student_id self.__credits = [] def add_credits(self, newlist): self.__credits += newlist def get_name(self): return

(Student.py)

class Student: def __init__(self, name, student_id): self.__name = name self.__id = student_id self.__credits = [] def add_credits(self, newlist): self.__credits += newlist def get_name(self): return self.__name def get_id(self): return self.__id def get_credits(self): return self.__credits 

(main.py)

from student import Student def create_students(filename): """ Return a list of students, that are created. Read a name and a student id (a number, that only one student have ( between 100000 and 999999)) of the new student to be created, from the given file. The name and the student id are separated by a '/'. If the file is somehow incorrect read the next line. You can assume that the program always finds the called file. RETURNS a list of created __Student__-objects EXAMPLE create_students(filename) file: Teemu Teekkari/123456 Tiina Teekkari/234567 this line is incorrect Kaisa Kemisti/345678 Kalle Kemisti/456789 returns: a list of 4 Student-objects """ pass**write your own code here def add_credits(student): """ Ask credits (whole numbers, int) from the user and add the input to __student__-object as a list of numbers. The credits are separeted from each others by a "," in user input. If the input is incorrect return False, and don't save any of the given credits, otherwise return True and save the credits to object. RETURNS True/False EXAMPLE add_credits(student) user input: "5,5,5,4,3,10,3,8,5,15,5" returns: True saves to student: 5,5,5,4,3,10,3,8,5,15,5 add_credits(student) user input: "5,5,5,,4,error,10,3,8,5,15,5" returns: False saves to student: """ pass #write your own code here 
def compare_student_numbers(student1, student2): """ Compare two given Student-objects __student1__ and __student2__, and return the one with a smaller id. Use this function in sort_with_credits()! You can expect that the are no errors in __student1__ or __student2__. RETURNS: a Student-object EXAMPLE: given objects: student1, id: 123456 student2, id: 234567 compare_student_numbers(student1, student2): returns: student1 """ pass #write your own code here def sort_with_credits(student_list): """ Return a sorted list of Student-objects, from __student_list__-list, so the credits of the objects are sorted in ascending order. If two objects has same amount of credits put them in student number order, use a function compare_student_numbers() to this! You can expect that there are no errors in __student_list__. RETURNS: a list: of Student-objects EXAMPLE: objects in students: object1, sum of credits: 104 id: 123456 object2, sum of credits: 26 id: 234567 object3, sum of credits: 254 id: 345678 object4, sum of credits: 104 id: 456789 students_by_grade(students) returns: [ object2 , object1 , object4 , object3 ] """ pass #write your own code here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!