Answered step by step
Verified Expert Solution
Question
1 Approved Answer
We need help with creating a constructor to find the distance between two points. We're trying to get the output in the prompt below: Test
We need help with creating a constructor to find the distance between two points. We're trying to get the output in the prompt below:
Test code. Do not change this.
Your solution to this problem must meet the following criteria. 1. You must define a class Point in the file point. py with two attributes. - an integer for x with a default of 0 - an integer for y with a default of 0 2. Create a three instance methods in the Point class. - a constructor that take two optional arguments for x and y distance formula. - a special instance method to return a formatted string "(x,y)" for the point object 4. Below is an example of a call to the Point class which you could implement in point_test.py to test your class. Python Code: import point point1 = point.Point (1,1) point2 = point.Point (1,5) print( "The distance between \{\} and \{\} is \{\} ".format( point1, point2, point1.get_distance_to(point2) ) Output: The distance between (1,1) and (1,5) is 4.0 import point point1 = point.Point (1,1) point2 = point.Point (1,5) print( "The distance between \{\} and \{\} is \{\}. format( point1, point2, point1.get_distance_to(point2) )
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started