Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

distance formula in python

import math.
def calculateDistance(x1,y1,x2,y2):
dist = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
return dist.
print calculateDistance(x1, y1, x2, y2)
Comment

how to make a distance function in python

import math
p1 = [4, 0]
p2 = [6, 6]
distance = math.sqrt( ((p1[0]-p2[0])**2)+((p1[1]-p2[1])**2) )

print(distance)
Comment

PREVIOUS NEXT
Code Example
Python :: # How to Prints the current working directory in python 
Python :: flask heroku 
Python :: call a function onclick tkinter 
Python :: end python program 
Python :: matplotlib boxplot colors 
Python :: loop through list of dictionaries python 
Python :: pandas return specific row 
Python :: color python 
Python :: django migrate not creating tables 
Python :: how to remove items from list in python 
Python :: flask migrate 
Python :: django dockerfile multistage 
Python :: 2d gaussian function python 
Python :: train_test_split sklearn 
Python :: how to find the data type in python 
Python :: how to convert binary to text in python 
Python :: how to detect when a key is pressed in pygame 
Python :: tuple length in python 
Python :: remove substring from string python 
Python :: tkinter allign 
Python :: count number of each item in list python 
Python :: import numpy financial python 
Python :: print list in python 
Python :: pathlib path get filename with extension 
Python :: pick a random number from a list in python 
Python :: concatenate python 
Python :: first and last digit codechef solution 
Python :: unittest skip 
Python :: pandas column filter 
Python :: how to convert timestamp to date in python 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =