PFP191_PE1_SU2025_4099.webp
T

PFP191_PE1_SU2025_4099.webp

Bài viết gốc: Chủ đề 'PFP191_PE1_SU2025'
☑Kizspy.me
Object-Oriented Programming (OOP) in Python. The system should read course data
from a given file named course_d
_data. txt, process the data, and implement specific
functionalities related to course registration and department analysis.
Question 1: Implement the Course Registration Class (2 Marks)

Create a Course Registration class with a constructor (__init__ ) to
initialize the following properties:
。 Public attributes:
о

course_id (string): Unique identifier of the course.
course_name (string): Name of the course.
instructor (string): Name of the course instructor.
department (string): Department offering the course.
Private attribute:
_ credit_hours (int): Number of credit hours for the course.
。 Implement getter and setter methods for the private attribute
_credit_hours to allow controlled access.
Question 2: Load Course Data from a File (3 Marks)
Write a function load_course_data (filename):
。 Reads course registration data from a file (e.g., "course_data.txt").
。 Handle FileNotFoundError if the specified file does not exist.
。 Parses the file content and creates a list of CourseRegistration objects.
。 Returns the list of course registrations.
Call load_course_data (file_not_found.txt) to show the error handler.
⚫ Call the function load_course_data (course_data.txt)
Store the returned list in a variable courses and print its content.
Zoom
+ 100%
Close
Chưa có bình luận nào.

Thông tin

Category
PFP191
Thêm bởi
ThuyPhuong86
Ngày thêm
Lượt xem
2,664
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom