69.1k views
5 votes
## Inputs

# Recieving two coordinate pairs
x1 = int(input("Please provide X1:\t"))
y1 = int(input("Please provide Y1:\t"))
x2 = int(input("Please provide X2:\t"))
y2 = int(input("Please provide Y2:\t"))

## Calculations


# distance formula
xDif = x2 - x1
yDif = y2 - y1
radical = xDif**2 + yDif**2
distance = radical ** (1/2) # meters
## Outputs

#Informing the user of distance between the two coordinate pairs
print("Distance between points:", distance, "meters")


1)If the distance is greater than 50 units, let the user know the points are very far apart

2) If the distance is less than 5 but greater than 0, inform the user the points are fairly close

3)If the distance is 0, inform the user that these points are the same

Can someone help me completing 1,2,3 in python

1 Answer

2 votes

# Recieving two coordinate pairs

x1 = int(input("Please provide X1:\t"))

y1 = int(input("Please provide Y1:\t"))

x2 = int(input("Please provide X2:\t"))

y2 = int(input("Please provide Y2:\t"))

## Calculations

# distance formula

xDif = x2 - x1

yDif = y2 - y1

radical = xDif**2 + yDif**2

distance = radical ** (1/2) # meters

## Outputs

if(distance>50):

print("The points are very far apart\\")

elif(distance<5 and distance>0):

print("The points are fairly close\\")

elif(distance==0):

print("These point are the same\\")

#Informing the user of distance between the two coordinate pairs

print("Distance between points:", distance, "meters")

User Nathan Prometheus
by
3.7k points