I want to find Euclidean distance between two points in Python.

Asked 2 years ago, Updated 2 years ago, 245 views

I want to feel this way, but it doesn't work.Please advise me if you understand.

p_x=(1,2,4)
p_y = (-2,2,0)
BEGIN
for i in p_x, p_y:
    i+=(p_x-p_y)**2
    distance=i**1/2
    
distance=i

END
print(distance)

python

2022-09-30 22:04

1 Answers

import path

distance=math.sqrt(sum(x-y)**2 for x, y in zip(p_x, p_y)))


2022-09-30 22:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.