Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago

Question

3. How would this philosophy fit in your organization?

Answered: 1 week ago