2021年5月1日星期六

How to use values in list from one function in a second function

I am working on coding a precalculous problem. I was able to write one function and get an (x,y) plot in a python list. I want to be able to call list[0] and list[1] of the first function in a second function. How do I setup my functions so that I can use the outputs from the first function as inputs in the second functions?

import numpy as np  import sympy as sy    # find the point of intersection of two points by using a linear function    def intersection(slope1, yintercept1, slope2, yintercept2):      xval = -1*slope1+slope2      recip = np.reciprocal(xval)      xval = yintercept1*recip      yval = slope2*xval      point = [xval, yval]      return point  print(intersection((sy.Rational(-6,7)), 9, sy.Rational(7,6), 0))    #find the distance two points are apart.    def distance(x, y):    #I want to call the point from my intersection function here and put them into the distance formula   to find out how far away the point is from the origin.       print(distance(0,0))  
https://stackoverflow.com/questions/67352879/how-to-use-values-in-list-from-one-function-in-a-second-function May 02, 2021 at 12:02PM

没有评论:

发表评论