Computer Science, asked by vishbk8909, 1 year ago

Vertices and Length of Diagonal of Square Given two adjacent vertices of a square, write an algorithm and the subsequent Python code to determine the length of the diagonal. Pythagorean theorem states that the square of the hypotenuse (the side opposite the right angle) is equal to the sum of the squares of the other two sides. For example, if the coordinates of the adjacent vertices of a square are given as (10, 15) and (20, 15) then the other two vertices in sorted order are (10, 25) and (20, 25) and length of the diagonal is 14.14. Print only two decimal places for length of the diagonal.

Answers

Answered by thotasaichaitanya272
0

x1=int(input(""))

y1=int(input(""))

x2=int(input(""))

y2=int(input(""))

import math

if x1==x2:

   l1=y2-y1

   x3=x1+l1

   y3=y1

   x4=x2+l1

   y4=y2

   D=math.sqrt((x4-x1)**2+(y4-y1)**2)

   

   a=(x3,y3)

   b=(x4,y4)

   

   print(a)

   print(b)

   

   print(round(D,2))

Similar questions