- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 Articles
- Check whether a given point lies inside a Triangle\n
- 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 if a given point lies inside a Polygon
- How To Check if a Given Point Lies Inside a Rectangle in Java?
- If the point ( (3,4) ) lies on the graph of the equation ( 3 y=a x+7 ), find the value of ( a ).
- Check whether given floating point number is even or odd in Python
- Point $P( x, 4)$ lies on the line segment joining the points $A( -5, 8)$ and $B( 4, -10)$. Find the ratio in which point P divides the line segment AB. Also find the value of x.
- Write the Co-ordinates of a point which lies on y-axis and is at a distance of 3 units above x-axis. Represent on the graph.
- If $R ( x, y)$ is a point on the line segment joining the points $P ( a, b)$ and $Q ( b, a)$, then prove that $a+b=x+y$
- If $R (x, y)$ is a point on the line segment joining the points $P (a, b)$ and $Q (b, a)$, then prove that $x + y = a + b$.
- The line segment joining the points ( A(3,2) ) and ( B(5,1) ) is divided at the point ( P ) in the ratio ( 1: 2 ) and it lies on the line ( 3 x-18 y+k=0 ). Find the value of ( k ).
- Check whether the given string is a valid identifier in Python
- A point P divides the line segment joining the points$A( 3, -5) $ and $B( -4, 8)$ such that$frac{AP}{PB} =frac{K}{1}$ . if P lies on the line $x+y=0$, then find the value of K.
- A point $P$ divides the line segment joining the points $A (3, -5)$ and $B (-4, 8)$ such that $frac{AP}{PB} = frac{k}{1}$. If $P$ lies on the line $x + y = 0$, then find the value of $k$.

Advertisements