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

In the previous article, we have discussed Python Program for Section Formula (Point that Divides a Line in Given Ratio)<\/a>
\nGiven two points of a line, the task is to find the slope of a given line.<\/p>\n

Let\u00a0 A(x1<\/sub>,y1<\/sub>) and B(x2<\/sub>,y2<\/sub>) are the two points on a straight line.<\/p>\n

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

Formula to find the slope of a given line is:<\/p>\n

slope=(y2-y1)\/(x2-x1)<\/p><\/blockquote>\n

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

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

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

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

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

The slope of the line for the given two points is :\r\n0.25<\/pre>\n

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

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

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

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

The slope of the line for the given two points is :\r\n1.0<\/pre>\n

Program to Find Slope of a Line in Python<\/h2>\n

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