

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
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))
Input
3, 5, (6,23)
Output
True
- Related Questions & Answers
- Check whether a given point lies inside a Triangle
- Check if a given point lies inside a Polygon
- Check if a point lies on or inside a rectangle in Python
- Program to check whether given list of blocks are symmetric over x = y line or not in python
- Check whether given floating point number is even or odd in Python
- Find maximum among x^(y^2) or y^(x^2) where x and y are given in C++
- Find a distinct pair (x, y) in given range such that x divides y in C++
- Check whether the given string is a valid identifier in Python
- Find if a point lies inside a Circle in C++
- Program to find nearest point that has the same x or y coordinate using Python
- Check if a number can be expressed as x^y (x raised to power y) in C++
- Evaluate a 2-D polynomial on the Cartesian product of x and y in Python
- Evaluate a 2D Legendre series on the Cartesian product of x and y in Python
- Check whether given key already exists in a dictionary in Python
- Find normal at a given point on the curve in C++
Advertisements