QUIZ 7 COMP9021 PRINCIPLES OF PROGRAMMING $ python3 ... >>> from quiz_7 import * >>> disk_1 = Disk() >>> disk_1 Disk(Point(0.00, 0.00), 0.00) >>> disk_1.area 0.0 >>> disk_2 = Disk(Point(3, 0), 4)...

1 answer below »
please include the comments of the steps done so that I can learn from it after.


QUIZ 7 COMP9021 PRINCIPLES OF PROGRAMMING $ python3 ... >>> from quiz_7 import * >>> disk_1 = Disk() >>> disk_1 Disk(Point(0.00, 0.00), 0.00) >>> disk_1.area 0.0 >>> disk_2 = Disk(Point(3, 0), 4) Traceback (most recent call last): File "", line 1, in TypeError: __init__() takes 1 positional argument but 3 were given >>> disk_2 = Disk(centre = Point(3, 0), radius = 4) >>> disk_2.area 50.26548245743669 >>> disk_1.intersects(disk_2) True >>> disk_2.intersects(disk_1) True >>> disk_3 = disk_1.absorb(disk_2) >>> disk_3 Disk(Point(3.00, 0.00), 4.00) >>> disk_1.change_radius(2) >>> disk_1.area 12.566370614359172 >>> disk_3 = disk_1.absorb(disk_2) >>> disk_1 Disk(Point(0.00, 0.00), 2.00) >>> disk_2 Disk(Point(3.00, 0.00), 4.00) >>> disk_3 Disk(Point(2.50, 0.00), 4.50) >>> disk_4 = Disk(centre = Point(-4, 0), radius = 2) >>> disk_4.intersects(disk_1) True Date: Session 2, 2018. 2 COMP9021 PRINCIPLES OF PROGRAMMING >>> disk_5 = disk_4.absorb(disk_1) >>> disk_5 Disk(Point(-2.00, 0.00), 4.00) >>> disk_5.change_radius(5) >>> disk_5 Disk(Point(-2.00, 0.00), 5.00) >>> disk_6 = Disk(centre = Point(1, 2), radius = 6) >>> disk_7 = disk_5.absorb(disk_6) >>> disk_7 Disk(Point(-0.08, 1.28), 7.30) >>> disk_7.area 167.54280759052247 >>> disk_8 = Disk() >>> disk_8 Disk(Point(0.00, 0.00), 0.00) >>> disk_8.change_radius(7) >>> disk_8.absorb(disk_7) Disk(Point(-0.05, 0.79), 7.79)
Answered Same DaySep 15, 2020COMP9021

Answer To: QUIZ 7 COMP9021 PRINCIPLES OF PROGRAMMING $ python3 ... >>> from quiz_7 import * >>> disk_1 = Disk()...

Snehil answered on Sep 17 2020
147 Votes
quiz_7.py
# Defines two classes, Point() and Disk().
# The latter has an "area" attribute and three methods:
# - change_radius(r)
# -
intersects(disk), that returns True or False depending on whether
# the disk provided as argument intersects the disk object.
# - absorb(disk), that returns a new disk object that represents the smallest
# disk that contains both the disk provided as argument and the disk object.
#
# Written by *** and Eric Martin for COMP9021
from math import pi, hypot
#Class to represent a point with x and y values
class Point:
#constructor for the point, initializing to 0,0
def __init__(self, x = 0, y = 0):
self.x = x
self.y = y

#Method to represent point as a string value
def __repr__(self):
return f'Point({self.x:.2f}, {self.y:.2f})'
#Class to represent a disk with a centre point and a radius value
class Disk:

#constructor for the Disk, initializing to the given arguments in the keword argument dictionary
def __init__(self, **kwargs):
self.centre = Point(0,0)
self.radius = 0
if 'centre' in kwargs: # if centre argument is provided
self.centre = kwargs.get('centre')
if 'radius' in kwargs:# if radius argument it provided
self.radius = kwargs.get('radius')
self.area = pi *...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here