{"id":22684,"date":"2021-09-27T15:43:07","date_gmt":"2021-09-27T10:13:07","guid":{"rendered":"https:\/\/python-programs.com\/?p=22684"},"modified":"2021-11-22T18:35:38","modified_gmt":"2021-11-22T13:05:38","slug":"python-program-to-find-the-mid-point-of-a-line","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-the-mid-point-of-a-line\/","title":{"rendered":"Python Program to Find the Mid-Point of a Line"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Find Line Passing Through 2 Points<\/a>
\nGiven two points of a line (which are the start and endpoints) and the task is to find the midpoint of the given line in python.<\/p>\n

The formula for the midpoint of a line:<\/strong><\/p>\n

Let the two points of a line are (x1, y2) and (x2, y2).<\/p>\n

The formula for midpoint is:<\/p>\n

Midpoint = ((x1<\/sub>+x2<\/sub>)\/2 , (y1<\/sub>+y2<\/sub>)\/2)<\/strong><\/p><\/blockquote>\n

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

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

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

Given First Point = ( 3 , 1 )\r\nGiven Second Point = ( 4 , 5 )<\/pre>\n

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

The Midpoint of the given line is:\r\n( 3 , 3 )<\/pre>\n

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

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

Given First Point = ( 6 , -2 )\r\nGiven Second Point = ( 7, 4 )<\/pre>\n

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

The Midpoint of the given line is:\r\n( 6 , 1 )<\/pre>\n

Program to Find the Mid-Point of a Line in Python<\/h2>\n

Below are the ways to find the midpoint of the given line in python:<\/p>\n