CJCoding With Joseph
15free / daySign inCreate account

Distance Between Points

A Point stores x and y. Write the body of distance_to, which receives another point as other and returns the straight-line distance between the two: the square root of the squared difference in x plus the squared difference in y. Raise to the power 0.5 with ** instead of importing a math module. Do NOT write a main block or any top-level test code; the tests construct the class. Input: two lines, the x then the y of the second point, which the tests read as floats; the first point is always (1, 1), and the tests print the distance your method returns.

Expected Output:

5.0

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
Classes
📥 Auto-Input:
4\n5\n
This input is automatically fed to your program's stdin
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.