from macslib import *
from math import *
# Remember to rename this function for the 2D version
def distance1D(x1, x2):
# add a variable for the y coordinate for the first point above
# add a variable for the y coordinate for the second point above
# change the distance calculation to use the 2D distance formula we derived
# to square something you need to write (x-y)**2
distance = sqrt( (x2 - x1)**2 )
print "Distance: " + str(distance)
# uncomment this line to see a plot of 2D distance!
# drawPoints([x1,x2], [y1,y2], title="Distance: " + str(distance), xaxis=["X",-10,10], yaxis=["Y",-10,10])
# Test to see how it works
distance1D(2, 4)