Question: Write a class Student with the following attributes (make sure the attributes are private using name mangling): name: String . id : Integer courses: List

 Write a class Student with the following attributes (make sure the

Write a class Student with the following attributes (make sure the attributes are private using name mangling): name: String . id : Integer courses: List of Strings grades: List of Integers The class must include the following operations: A constructor that receives as input the name and id. Getters for each attribute. . add_course(course: String, grade: Integer) : Bool This operation adds the course name to the list of courses and the grade to the list of grades. The method must confirm before adding that the course is a string and the grade is an Integer, otherwise the operation won't be performed. The method must return True if the course and grades were added, False otherwise _str_0 -- Should return the following information Student name: -- Courses passed: " Courses passed means courses with a grade equal to 60 or larger. Check the testcase for details. pass ratio(): Float -- Returns the pass ratio as a percentage of the courses passed respect to the total of courses (the percent must the rounded to two numbers after the digits). Check the testcase for details. course_from_file(filename: String) -- Reads the courses names and grades from a text file and adds them to the corresponding lists. The file has one course-grade per line separated by a semicolon. You can assume the filename passed as parameter does exist (i.e. you do not have to check if the file exists). For example: Test Result # Testing constructor and ID and name getters Li Wei student = Student ("L1 Wei", 213987) 213987 print(student.get_name())

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!