24.0k views
5 votes
Two polygons are said to be similar if their corresponding angles are the same or if each pair of corresponding sides has the same ratio. Write the code to test if two rectangles are similar when the length and width of each are provided as integer values. For example:If the rectangles have lengths of 10 and 8, the ratio would be 1.25.

1 Answer

0 votes

Answer:

Step-by-step explanation:

Let's do this in Python. We will assume there are 4 user inputs. L1, W1 are the length and width of the first rectangle, respectively. L2, and W2 are the length and width of the 2nd rectangle. We can check if they are similar by comparing their ratios.

def check_similar(L1, W1, L2, W2):

if L1/L2 == W2/W2:

return True

else:

return False

User Pievis
by
5.3k points