Menu

(Solved) : Given Python Code Superclass Course B Many Instances Course Created C First Invocation Inh Q26177636 . . .

Given the python code below:  

class Course (list) An example for reviewing classes in python csMajorCour ses = [] otherCour ses = [] def init (self, cname, isCore) self. cours ename = cname self.isCore-isCore self.prerequisites [] if( isCore self.csMajorCourses.append (self) else: self.otherCourses.append (self)] def prereuisite (self, preCourse) self.prerequisites.append (preCourse) return self.prerequisites def str (self): return self.coursename mycourseCourse (COMP2005, True) mycourse.prerequisite( Course (COMP2001, True)) for c in (COMP2006, COMP2007, COMP2008) : Course (c, True) mycourse.extend ( (Bob, Harriet, Jonas, Ahmed, Franklin) ) print (mycourse.pop )) print (mycourse)

A) What is the superclass of Course?

B) How many instances of Course are created?

C) The first invocation of an inherited method by a Courseobject is an invocation of the method named?

D) There is a usual python naming convention to indicate a classattribute is to be treated as a private attribute. If we apply thisconvention to the name of the first instance variable (also calledan instance data member) of the class Course, the name of thatvariable should be changed to?

class Course (list) “””An example for reviewing classes in python””” csMajorCour ses = [] otherCour ses = [] def init (self, cname, isCore) self. cours ename = cname self.isCore-isCore self.prerequisites [] if( isCore self.csMajorCourses.append (self) else: self.otherCourses.append (self)] def prereuisite (self, preCourse) self.prerequisites.append (preCourse) return self.prerequisites def str (self): return self.coursename mycourseCourse (“COMP2005”, True) mycourse.prerequisite( Course (“COMP2001”, True)) for c in (“COMP2006”, “COMP2007”, “COMP2008”) : Course (c, True) mycourse.extend ( (“Bob”, “Harriet”, “Jonas”, “Ahmed”, “Franklin”) ) print (mycourse.pop )) print (mycourse) Show transcribed image text

Expert Answer


Answer to Given Python Code Superclass Course B Many Instances Course Created C First Invocation Inh Q26177636 . . .

OR