Create a function make_line, whose input is the list ? of coordinates (?,?) , and whose output is the equation of a line (in the variable ? ) with slope ? , going through ? .
from sympy import *
x = symbols('x')
def make_line(s,p):
# type your answer here
from sympy import *
x = symbols('x')
def make_line(s,p):
# equation of line passing through point (a,b) with slope s is
# y = s(x - a) + b
# X coordinate is p[0] and y coordinate is p[1]
a = p[0]
b = p[1]
return s*(x - a) + b
y = (make_line(2,[4,7]))
print("y =",y)
I have added comments to explain the logic behind the code. Please play around with different values of p and s to get a sense of how the code works.
The output is-
I would love to resolve any queries in the comments. Please consider dropping an upvote to help out a struggling college kid :)
Happy Coding !!
Get Answers For Free
Most questions answered within 1 hours.