(10 points) Make a user interface to get 3 points from the user which will be placed on the coordinate plane. Then write a Python3 function to check whether the points entered forms a right triangle. And another Python3 function to check whether the points entered forms a equilateral triangle. Call your functions for three user-entered points on the coordinate plane.

Respuesta :

Answer:

def cord_input():

Global coordinates

coordinates = {'x1': 0, 'y1': 0, 'x2':0, 'y2':0, 'x3':0, 'y3':0}

for key, i in enumerate(coordinates.keys()):

if i < 2:

index = 1

coordinates [key] = float(input(f"Enter {key} coordinate for point {index}: "))

elif i >= 2 and i < 4:

index = 2

coordinates [key] = float(input(f"Enter {key} coordinate for point {index}: "))

else:

index = 3

coordinates [key] = float(input(f"Enter {key} coordinate for point {index}: "))

def sides(p1, p2, p3):

nonlocal a, b, c

a = ((p2[0] - p1[0])**2) + ((p2[1] - p1[1])**2)

b = ((p3[0] - p2[0])**2) + ((p3[1] - p2[1])**2)

c = ((p3[0] -p1[0])**2) + ((p3[1] - p2[1])**2)

def is_right_triangle(p1, p2, p3):

sides(p1, p2, p3)

if a+b == c or b+c == a or a+c == b:

print(f"Sides {a}, {b} and {c}")

return True

else:

return False

def is_equilateral(p1, p2, p3):

sides(p1, p2, p3)

if a==b and b==c:

print(f"Sides {a}, {b} and {c}")

return True

else:

return False

cord_input()

Explanation:

The python code above defines four functions, cord_input (to input a global dictionary of coordinates), sides ( to calculate and assign the sides of the triangle), is_right_triangle ( to check if the coordinates are for a right-angle triangle), and is_equilateral for equilateral triangle check.

ACCESS MORE