Disk

A (circular, solid) disk in the plane is completely determined by its radius and its centre (given as x- and y-coordinates). Define a class Disk for representing such disks. Instances of your class should have the following methods:
• init (self, r, x, y) which assigns r to the instance variable radius and assigns x and y to the instance variables centre_x and centre_y , respectively. If r 3 e , then the method should execute the statement
raise valueError
A radius of a is allowed. (What is the geometric meaning of this?)
• diameter (self ) which computes and returns the diameter of a disk.
• area (self ) which computes and returns the area of a disk.
• distance(self, other) which computes and returns the distance between two disks. Given disks D, and D0, where D, has centre (x,, )0 and radius r,, the distance between D, and D, is the maximum of 0 and xx./’ EY] — Y2/2 — —
•_repr_(self) which returns a representation of a disk as a string. This method is already provided below so you do not need to write it yourself.

×
New Download