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__() -- 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 with respect to the total of courses (the percent must the rounded to two numbers after the digits). Check the testcase for details. Note: 4 of 7 courses would be 4/7 = 0.57142857... which would be returned as 57.14 courses_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).
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__() -- 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 with respect to the total of courses (the percent must the rounded to two numbers after the digits). Check the testcase for details. Note: 4 of 7 courses would be 4/7 = 0.57142857... which would be returned as 57.14 courses_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).
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
Related questions
Question
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__() -- Should return the following information "Student name: <name> -- Courses passed: <number of 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 with respect to the total of courses (the percent must the rounded to two numbers after the digits). Check the testcase for details. Note: 4 of 7 courses would be 4/7 = 0.57142857... which would be returned as 57.14
- courses_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).
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education