Check whether the point (x, y) lies on a given line in Python

Suppose we have a straight line in the form y = mx + b, where m is slope and b is y-intercept. And have another coordinate point (x, y). We have to check whether this coordinate point lies on that straight line or not.

So, if the input is like m = 3 b = 5 point = (6,23), then the output will be True as if we put the given x and y coordinate values on the straight line equation then it will satisfy.

To solve this, we will follow these steps −

  • if y of point is same as (m * x of point) + b, then
    • return True
  • return False

Let us see the following implementation to get better understanding −

Example Code

Live Demo

def solve(m, b, point):
   if point[1] == (m * point[0]) + b: 
      return True
   return False
m = 3
b = 5
point = (6,23)
print(solve(m, b, point))


3, 5, (6,23)