Question

Create a function make_line, whose input is the list ? of coordinates (?,?) , and whose...

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

Homework Answers

Answer #1
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 !!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
IN SML Write a function dupList of type 'a list -> 'a list whose output list...
IN SML Write a function dupList of type 'a list -> 'a list whose output list is the same as the input list but with each element of the input list repeated twice in a row. For example, if the input is [1, 2, 3], the output list should produce [1, 1, 2, 2, 3, 3]. If the input list [], the output list should be []. Do not use explicit recursion but use one of the fold functions. Do...
IN ML(NOT PYTHON) Write a function dupList of type 'a list -> 'a list whose output...
IN ML(NOT PYTHON) Write a function dupList of type 'a list -> 'a list whose output list is the same as the input list but with each element of the input list repeated twice in a row. For example, if the input is [1, 2, 3], the output list should produce [1, 1, 2, 2, 3, 3]. If the input list [], the output list should be []. Do not use explicit recursion but use one of the fold functions....
(USING ML) (Using ML) Write a function dupList of type 'a list -> 'a list whose...
(USING ML) (Using ML) Write a function dupList of type 'a list -> 'a list whose output list is the same as the input list but with each element of the input list repeated twice in a row. For example, if the input is [1, 2, 3], the output list should produce [1, 1, 2, 2, 3, 3]. If the input list [], the output list should be []. Do not use explicit recursion but use one of the fold...
create a function that takes a dictionary and returns a list of int. The list should...
create a function that takes a dictionary and returns a list of int. The list should appear in decreasing order based on the sum of number in each dictionary. def total_num(dict1): #Code here input = {1: {'una': 5, 'dos': 7, 'tres': 9, 'quar' : 11}, 2: {'dos':2, 'quar':3}, 3:{'una': 3, 'tres': 5}, 4:{'cin': 6}, 5:{'tres': 7 , 'cin': 8}} output = [1,5,3,4,2] 1: 38 2: 5 3: 8 4: 6 5: 15 1>5>3>4>2
Create a C program that evaluates the function 3x + 7. Your input will consist of...
Create a C program that evaluates the function 3x + 7. Your input will consist of a number of lines, each containing a single integer number. For each number x that is provided in the input, you should output 3x + 7 as a single integer number. Each number your program prints has to occupy a separate line. No other character should be sent to the output other than the digits of the number (and possible sign) and the newline...
Write regular expressions that will match IP addresses and usernames in a Microsoft IIS log file....
Write regular expressions that will match IP addresses and usernames in a Microsoft IIS log file. First, you will write a regular expression that matches IP addresses within the re.compile function call on line 36. Next, you will write a regular expression that matches usernames (in the format domain\username) on line 50. Finally, in steps 3 and 4 you will write a loop for each step that displays all the IP addresses (gathered into the list ipAddresses) and usernames (gathered...
Give the slope and​ y-intercept of the line whose equation is given below. Then graph the...
Give the slope and​ y-intercept of the line whose equation is given below. Then graph the linear function. y equals -7x + 5 The slope of the line is -7? ​(Simplify your​ answer.) The​ y-intercept is 5? ​(Type an integer or a simplified​ fraction.) Use the graphing tool to graph the linear equation. Use the slope and​ y-intercept when drawing the line. Please help verify, I don't understand the calculation to graph the linear function?
** Language Used : Python ** PART 2 : Create a list of unique words This...
** Language Used : Python ** PART 2 : Create a list of unique words This part of the project involves creating a function that will manage a List of unique strings. The function is passed a string and a list as arguments. It passes a list back. The function to add a word to a List if word does not exist in the List. If the word does exist in the List, the function does nothing. Create a test...
from typing import List def longest_chain(submatrix: List[int]) -> int: """ Given a list of integers, return...
from typing import List def longest_chain(submatrix: List[int]) -> int: """ Given a list of integers, return the length of the longest chain of 1's that start from the beginning. You MUST use a while loop for this! We will check. >>> longest_chain([1, 1, 0]) 2 >>> longest_chain([0, 1, 1]) 0 >>> longest_chain([1, 0, 1]) 1 """ i = 0 a = [] while i < len(submatrix) and submatrix[i] != 0: a.append(submatrix[i]) i += 1 return sum(a) def largest_rectangle_at_position(matrix: List[List[int]], x:...
Use the given conditions to write an equation for the line in​ point-slope form and general...
Use the given conditions to write an equation for the line in​ point-slope form and general form. Passing through (1,-3) and perpendicular to the line whose equation is x-6y-5=0. The equation of the line in​ point-slope form is _ .(Type an equation. Use integers or fractions for any numbers in the​ equation.) The equation of the line in general form is ___ = 0 ​(Type an expression using x and y as the variables. Simplify your answer. Use integers or...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT