{"id":22657,"date":"2021-09-27T08:36:58","date_gmt":"2021-09-27T03:06:58","guid":{"rendered":"https:\/\/python-programs.com\/?p=22657"},"modified":"2021-11-22T18:35:38","modified_gmt":"2021-11-22T13:05:38","slug":"python-program-to-check-if-three-points-are-collinear","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-check-if-three-points-are-collinear\/","title":{"rendered":"Python Program to Check if Three Points are Collinear"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Find Sum of Series 1^1\/1!+2^2\/2!+3^3\/3!…+n^n\/n!<\/a>
\nGiven three points the task is to check whether the given three points are collinear or not in Python.<\/p>\n

Collinear Points:<\/strong><\/p>\n

Collinear points are those that are located along the same straight line or in a single line. In Euclidean geometry, two or more points on a line that is close to or far from each other are said to be collinear.<\/p>\n

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

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

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

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

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

The points ( 1 , 1 ) ( 1 , 4 ) ( 1 , 5 ) are collinear and lies on the straight line<\/pre>\n

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

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

Given First Point = ( 7 , 0 )\r\nGiven Second Point = ( 8, 9 )\r\nGiven Third Point = ( 1, 2 )<\/pre>\n

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

The points ( 7 , 0 ) ( 8 , 9 ) ( 1 , 2 ) are not collinear<\/pre>\n

Program to Check if Three Points are Collinear in Python<\/h2>\n

Below are the ways to check whether the given three points are collinear or not in Python:<\/p>\n