Question: programming 5 1 1 python: Question 1 ( 2 5 marks ) 1 . Explain how the following set operations work: ( 7 marks )

programming 511 python:
Question 1(25 marks)
1. Explain how the following set operations work: (7 marks)
a. Union
b. Intersection
c. Difference
2. Discuss the four characteristics of Object-Oriented Programming. (8 marks)
3. Define the following terms: (10 marks)
a. Database
b. Record
c. Field
d. Primary Key
e. Foreign Key
Question 2(25 marks)
Implement a University Course Management System using Object-Oriented Programming
principles in Python. The system should manage courses, students, and professors. Create the
following classes with their respective attributes and methods:
a. Create a Person class with name, age, and ID attributes. Implement an init method to initialise
these attributes and a str method to return a string representation of a Person object.
b. Develop a Student class that inherits from the Person class. In addition to the inherited
attributes, include a major and a list of enrolled_courses. Implement an enrol(course) method
that adds a course to the student's enrolled_courses if there's capacity in the course. Also,
create a drop(course) method that removes a course from the student's enrolled_courses.
c. Create a Professor class that inherits from the Person class. Add attributes for the department
and a list of courses_teaching. Implement an assign_course(course) method that adds a
course to the professor's courses_teaching list and sets the course's professor attribute to this
professor.
d. Design a Course class with attributes for course_code, name, max_capacity, professor, and a
list of enrolled_students. Implement init and str methods, add_student(student) and
remove_student(student) methods. The add_student method should add a student to the
course if there's capacity, while the remove_student method should remove a student from
the course.
e. Develop a University class with attributes for names and lists of courses, students, and
professors. Implement methods to add_course(course), add_student(student), and
add_professor(professor) to their respective lists. Also, create a get_course(course_code)
method that returns a course given its course code.
Create a demo script that instantiates the University class and populates it with courses, students,
and professors. Demonstrate the functionality by enrolling students in courses, assigning
professors to courses, dropping students from courses, and printing out the state of courses,
students, and professors after these operations

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 Programming Questions!