class Point: def _init_(self, p_x, P_y): self.x = P_x self.y - P_y def distance(self, P2): # Compute and return the distance between the # two points and return it def closer(self, P2, P3): # Return the point that is closer to this point def _str_(self): # Return a string representation of this point # according to the format: "(x,y)"
class Point: def _init_(self, p_x, P_y): self.x = P_x self.y - P_y def distance(self, P2): # Compute and return the distance between the # two points and return it def closer(self, P2, P3): # Return the point that is closer to this point def _str_(self): # Return a string representation of this point # according to the format: "(x,y)"
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
with python and should not contain import and test code
![you will complete the following class which defines a simple 2-dimensional point and certain methods on it.
class Point:
def _init_(self, p_x, p_y):
self.x = P_x
self.y = p_y
def distance(self, P2):
# Compute and return the distance between the
# two points and return it
def closer(self, P2, P3):
# Return the point that is closer to this point
def _str_(self):
# Return a string representation of this point
# according to the format: "(x,y)"
You are already given the initializer for the class. Now, you have to complete the three methods: distance, closer and_str_. The distance method computes the
distance between this point and a point provided as argument to this method. It returns a float representing the distance. The closer method takes two other points and
returns the point object that is closer to this point. For example, p1.closer(p2,p3) returns p2, if p1 is closer to p2 compared to p3. Otherwise, it returns p3. Finally
str_returns a string representation of the point in the format (x,y).](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F525d966b-06b3-42ce-91cd-b1648e2047d2%2F4da14695-ab20-4162-82b3-a360f3058295%2Fb9conq_processed.png&w=3840&q=75)
Transcribed Image Text:you will complete the following class which defines a simple 2-dimensional point and certain methods on it.
class Point:
def _init_(self, p_x, p_y):
self.x = P_x
self.y = p_y
def distance(self, P2):
# Compute and return the distance between the
# two points and return it
def closer(self, P2, P3):
# Return the point that is closer to this point
def _str_(self):
# Return a string representation of this point
# according to the format: "(x,y)"
You are already given the initializer for the class. Now, you have to complete the three methods: distance, closer and_str_. The distance method computes the
distance between this point and a point provided as argument to this method. It returns a float representing the distance. The closer method takes two other points and
returns the point object that is closer to this point. For example, p1.closer(p2,p3) returns p2, if p1 is closer to p2 compared to p3. Otherwise, it returns p3. Finally
str_returns a string representation of the point in the format (x,y).
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY