{"id":23800,"date":"2021-10-03T20:32:01","date_gmt":"2021-10-03T15:02:01","guid":{"rendered":"https:\/\/python-programs.com\/?p=23800"},"modified":"2021-11-22T18:33:25","modified_gmt":"2021-11-22T13:03:25","slug":"python-program-for-maximum-area-of-quadrilateral","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-maximum-area-of-quadrilateral\/","title":{"rendered":"Python Program for Maximum Area of Quadrilateral"},"content":{"rendered":"
Given four sides of a quadrilateral, the task is to get the maximum area of the given quadrilateral for the given four sides in python.<\/p>\n
Quadrilateral:<\/strong><\/p>\n In geometry, a quadrilateral is a closed shape formed by joining four points, any three of which are non-collinear. A quadrilateral is made up of four sides, four angles, and four vertices. The term ‘quadrilateral’ is derived from the Latin words ‘quadra’ (four) and ‘Latus’ (sides). A quadrilateral’s four sides may or may not be equal.<\/p>\n Formula:<\/strong><\/p>\n The formula to calculate the maximum area of the given quadrilateral is :<\/p>\n <\/p>\n This is known as\u00a0 Brahmagupta’s Formula.<\/p>\n s=(a+b+c+d)\/2<\/strong><\/p>\n where a, b, c, d are the four sides of a quadrilateral.<\/p><\/blockquote>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Below are the ways to get the maximum area of the given quadrilateral for the given four sides in python:<\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Output:<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":" Given four sides of a quadrilateral, the task is to get the maximum area of the given quadrilateral for the given four sides in python. Quadrilateral: In geometry, a quadrilateral is a closed shape formed by joining four points, any three of which are non-collinear. A quadrilateral is made up of four sides, four angles, …<\/p>\nGiven first side = 2\r\nGiven second side = 1\r\nGiven third side = 3\r\nGiven fourth side = 4<\/pre>\n
The maximimum area of quadrilateral for the given four sides { 2 , 1 , 3 , 4 } = 4.898979485566356<\/pre>\n
Given first side = 5\r\nGiven second side = 3\r\nGiven third side = 5\r\nGiven fourth side = 2<\/pre>\n
The maximimum area of quadrilateral for the given four sides { 5 , 3 , 5 , 2 } = 12.43734296383275<\/pre>\n
Program for Maximum Area of Quadrilateral in Python<\/h2>\n
\n
Method #1: Using Mathematical Formula (Static Input)<\/h3>\n
\n
# Import math module using the import keyword.\r\nimport math\r\n# Give the first side as static input and store it in a variable.\r\np = 2\r\n# Give the second side as static input and store it in another variable.\r\nq = 1\r\n# Give the third side as static input and store it in another variable.\r\nr = 3\r\n# Give the fourth side as static input and store it in another variable.\r\ns = 4\r\n# Calculate the s value using the above given mathematical formula and\u00a0\r\n# store it in another variable.\r\ns_valu = (p + q + r + s) \/ 2\r\n# Calculate the maximum area of the given quadrilateral using the above\r\n# given mathematical formula, math.sqrt() function and store it in another variable.\r\nquadriltrlmax_area = math.sqrt(\r\n (s_valu - p) * (s_valu - q) * (s_valu - r) * (s_valu - s))\r\n# Print the maximum area of the given quadrilateral.\r\nprint(\r\n \"The maximimum area of quadrilateral for the given four sides {\", p, \",\", q, \",\", r, \",\", s, \"} = \", quadriltrlmax_area)\r\n<\/pre>\n
# include <iostream>\r\n# include<cmath>\r\nusing namespace std\r\n\r\nint main() {\r\n int p = 2\r\n int q = 1\r\n int r = 3\r\n int s = 4\r\n int s_valu = (p + q + r + s) \/ 2\r\n double quadriltrlMaxArea = sqrt((s_valu - p) * (s_valu - q) * (s_valu - r) * (s_valu - s))\r\n cout << \"The maximimum area of quadrilateral for the given four sides {\" << p << \",\" << q << \",\" << r << \",\" << s << \"} = \" << quadriltrlMaxArea << endl\r\n return 0\r\n}\r\n<\/pre>\n
The maximimum area of quadrilateral for the given four sides { 2 , 1 , 3 , 4 } = 4.898979485566356<\/pre>\n
Method #2: Using Mathematical Formula (User Input)<\/h3>\n
\n
# Import math module using the import keyword.\r\nimport math\r\n# Give the first side as user input using the int(input()) function and store it in a variable.\r\np = int(input(\"Enter some random number = \"))\r\n# Give the second side as user input using the int(input()) function and store it in another variable.\r\nq = int(input(\"Enter some random number = \"))\r\n# Give the third side as user input using the int(input()) function and store it in another variable.\r\nr = int(input(\"Enter some random number = \"))\r\n# Give the fourth side as user input using the int(input()) function and store it in another variable.\r\ns = int(input(\"Enter some random number = \"))\r\n# Calculate the s value using the above given mathematical formula and\u00a0\r\n# store it in another variable.\r\ns_valu = (p + q + r + s) \/ 2\r\n# Calculate the maximum area of the given quadrilateral using the above\r\n# given mathematical formula, math.sqrt() function and store it in another variable.\r\nquadriltrlmax_area = math.sqrt(\r\n (s_valu - p) * (s_valu - q) * (s_valu - r) * (s_valu - s))\r\n# Print the maximum area of the given quadrilateral.\r\nprint(\r\n \"The maximimum area of quadrilateral for the given four sides {\", p, \",\", q, \",\", r, \",\", s, \"} = \", quadriltrlmax_area)\r\n<\/pre>\n
Enter some random number = 5\r\nEnter some random number = 3\r\nEnter some random number = 5\r\nEnter some random number = 2\r\nThe maximimum area of quadrilateral for the given four sides { 5 , 3 , 5 , 2 } = 12.43734296383275<\/pre>\n