{"id":22988,"date":"2021-09-29T20:14:46","date_gmt":"2021-09-29T14:44:46","guid":{"rendered":"https:\/\/python-programs.com\/?p=22988"},"modified":"2021-11-22T18:35:34","modified_gmt":"2021-11-22T13:05:34","slug":"python-program-to-find-coordinates-of-rectangle-with-given-points-lie-inside","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-coordinates-of-rectangle-with-given-points-lie-inside\/","title":{"rendered":"Python Program to Find Coordinates of Rectangle with Given Points Lie Inside"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Find Number of Rectangles in N*M Grid<\/a>
\nGiven Two lists X and Y where X[i] and Y[i] represent the coordinate system’s points.<\/p>\n

The task is to Find the smallest rectangle in which all of the points from the given input are enclosed, and the sides of the rectangle must be parallel to the Coordinate axis. Print the obtained rectangle’s four coordinates.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given X Coordinates List = [<\/code>4<\/code>, <\/code>3<\/code>, <\/code>6<\/code>, <\/code>1<\/code>, <\/code>-<\/code>1<\/code>, <\/code>12<\/code>]\u00a0<\/code> Given Y Coordinates List = [<\/code>4<\/code>, <\/code>1<\/code>, <\/code>10<\/code>, <\/code>3<\/code>, <\/code>7<\/code>, <\/code>-<\/code>1<\/code>] <\/code><\/pre>\n

Output:<\/strong><\/p>\n

The first point of Rectangle is [ -1 , -1 ]\r\nThe second point of Rectangle is [ -1 , 10 ]\r\nThe third point of Rectangle is [ 12 , 10 ]\r\nThe fourth point of Rectangle is [ 12 , -1 ]<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given X Coordinates List =  4 8 7 1 6 4 2\r\nGiven Y Coordinates List =  5 7 9 8 3 4 2<\/pre>\n

Output:<\/strong><\/p>\n

The first point of Rectangle is [ 1 , 2 ]\r\nThe second point of Rectangle is [ 1 , 9 ]\r\nThe third point of Rectangle is [ 8 , 9 ]\r\nThe fourth point of Rectangle is [ 8 , 2 ]<\/pre>\n

Program to Find Coordinates of Rectangle with Given Points Lie Inside in Python<\/h2>\n

Below are the ways to Find the smallest rectangle in which all of the points from the given input are enclosed in Python:<\/p>\n