Question: Starting with your solution to the previous task, extend the MyLine class by implementing the special __repr__ method. The __repr__(self) method should return a string
Starting with your solution to the previous task, extend the MyLine class by implementing the special __repr__ method. The __repr__(self) method should return a string that unambiguously describes the object. For example, the following code fragment:
c1 = MyLine(10, 20, 20, 30) print(repr(c1))
produces
MyLine(10, 20, 20, 30)
Submit the entire class definition in the answer box below. You can assume that the MyPoint class is given.
For example:
| Test | Result |
|---|---|
line1 = MyLine(10, 20, 20, 30) print(repr(line1)) line2 = MyLine() print(repr(line2)) print(type(line1.start_point)) | MyLine(10, 20, 20, 30) MyLine(0, 0, 0, 0) |
line1 = MyLine() line1.start_point = MyPoint(100, 200) line1.end_point = MyPoint(-100, 40) print(repr(line1)) | MyLine(100, 200, -100, 40) |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
