• +91 9723535972
  • info@interviewmaterial.com

Data Science Interview Questions and Answers

Question - Write a function to calculate the Euclidean distance between two points.

Answer -

The formula for calculating the Euclidean distance between two points (x1, y1) and (x2, y2) is as follows:

√(((x1 - x2) ^ 2) + ((y1 - y2) ^ 2))
Code for calculating the Euclidean distance is as given below:

def euclidean_distance(P1, P2):
return (((P1[0] - P2[0]) ** 2) + ((P1[1] - P2[1]) ** 2)) ** .5

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners