Question: A point in two - dimensions can be represented by an x - and y - coordinate. In this problem, you will write a Point

A point in two-dimensions can be represented by an x- and y-coordinate. In this problem, you will write a Point class to store and work with such points.
The __init__ definition for the Point class is provided. Note that this accepts two arguments: the x- and y-coordinates of the point.
Also included is the __repr__ method, which outputs a canonical string representation of the point. Do not change this method, as we use it for tests. Note that the output of __repr__ could be copied into the interpreter in order to create an identical point. This is a characteristic of good __repr__ methods.
Task
Write a methoddist_to_point(self, other: Point)-> float
that returns the Euclidean distance between the points self and other. You may use math.sqrt.
Write a method is_near(self, other: Point)-> bool
that determines if two points are close. Two points are considered close if their Eucldiean distance is less than the global constant EPSILON.
Remember that you can use dist_to_point in this method by evoking self.dist_to_point.
Write a method add_point(self, other: Point)-> None
that adds the x (and y) component of other to the x (and y) component of self. Note this method returns None and therefore the change only modifies the current instance of self.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!