← Back to Classes
Question 510
Points That Move And Measure
Points That Move And Measure
Write the whole Point class. The constructor stores x and y as floats; move(dx, dy) shifts the point in place by adding dx to x and dy to y; distance_to(other) returns the straight-line distance to another point, the square root of the squared x gap plus the squared y gap, using ** 0.5 rather than a math import. Do NOT write a main block or any top-level test code; the tests construct the class. Input: two lines, dx then dy, which the tests read as floats and pass to move on a point that starts at (0, 0); they then print the moved x and y on one line and, on the next, the distance from a second point still at (0, 0).
Expected Output:
3.0 4.0 5.0
= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Classes
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.