Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please note that this is all one question with parts in it if you dont know how

ID: 3821460 • Letter: P

Question

please note that this is all one question with parts in it if you dont know how to answer them all dont even bother to do it ...

Section 14: Final practice (Thursday, April 20) Exercises: Solve the following one (1) Self Check problem on paper and bring your sheet of paper to your section on Thursday 1. Inheritance. Assume that the following classes have been defined: class George (Sally): def method2 print george 2 class Fred: def method 1 print fred 1") def method2 print ("fred 2'') def str fred class Harold (Sally): def str return harold class Sally (Fred) def method 1 print ("sally 1" def str return sally Consider the following code fragment: elements [Sally Fred George Harold for i in range (0, len (elements print (elements [i]) elements method1 elements method2 print t() What output is produced by this code? (write the output as a series of 3-line columns in order from left to right)

Explanation / Answer

As Sally is not defined before George it will not run. So moved George and Harold After Sally.

Then next issue is __str__ is expecting no argument but in python it will always pass self. So added that.

Similarly method1 and method2 expect no argument but python will send self, so added that as well.

Then in Fred as __str__ is supposed to return string (otherwise none type is returned which will cause issue) so made it return "fred" instead of just "fred"

After all this fix this will be output (adding it as column of 3 as requested in question instead of what python will print)

sally
sally 1
fred 2 fred
fred 1
fred 2 sally
sally 1
george 2 harold
sally 1
fred 2