Hugo888 发表于 2021-3-2 18:26:17

关于求二元一次函数和一元二次函数

这是我们学校的一个quiz,然后我搞了半天没搞出来过来求大神指点一下

Hugo888 发表于 2021-3-2 18:27:16

line((0, 0), (0, 0))
>>> line((0, -3), (0, 0))
'x = 0.00'
>>> line((-3, -3), (-3, 7))
'x = -3.00'
>>> line((8, 0), (5, 0))
'y = 0.00'
>>> line((8, 3), (-5, 3))
'y = 3.00'
>>> line((-3, -3), (0, 0))
'y = 1.00x'
>>> line((3, -3), (0, 0))
'y = -1.00x'
>>> line((1, 2), (2, 3))
'y = 1.00x + 1.00'
>>> line((-1, -2), (0, -1))
'y = 1.00x - 1.00'
>>> line((3, -3), (2, -4))
'y = 1.00x - 6.00'
>>> line((12, 5), (13, 29))
'y = 24.00x - 283.00'
>>> line((-1, -2), (7, 8))
'y = 1.25x - 0.75'
>>> line((-231, 87240), (73, 2987452))
'y = 9540.17x + 2291019.51'
>>> parabola()
>>> parabola(1, 0, 2)
>>> parabola(0)
'x^2 = 0'
>>> parabola(1, 1, 1, 1)
'x^2 - 2x + 1 = 0'
>>> parabola(1, 0, 0, 1, 1, 0, 1)
'x^2 - x = 0'
>>> parabola(7, -4, 7)
'x^2 - 3x - 28 = 0'
>>> parabola(-3, -11)
'x^2 + 14x + 33 = 0'
>>> parabola(100, -4, -4, -4, 100)
'x^2 - 96x - 400 = 0'

Hugo888 发表于 2021-3-2 18:28:17

def line(point_1, point_2):
    '''It can be assumed that point_1 and point_2 are both
    tuples of 2 integers.
   
    The function is meant to return a string that represents the equation
    of a line that goes through both points, in case they are different;
    otherwise, the function returns None.

    - If the line is vertical, then the function returns a string of the
      form 'x = b', with b the representation of a floating point number
      with 2 digits after the decimal point.
    - If the line is horizontal, then the function returns a string of the
      form 'y = b', with b the representation of a floating point number
      with 2 digits after the decimal point.
    - If the line is neither horizontal nor vertical, then
      - either the intercept is 0, in which case the function returns
          a string of the form 'y = ax', with a the representation of a
          floating point number with 2 digits after the decimal point;
      - or the intercept is not 0, in which case the function returns
          a string of the form 'y = ax ± b' with a and b representations
          of floating point numbers with 2 digits after the decimal point,
          and with b positive.
    '''
    return ''

Hugo888 发表于 2021-3-2 18:29:09

有大神帮忙不,有偿,vx clingme

wp231957 发表于 2021-3-2 18:59:03

Hugo888 发表于 2021-3-2 18:29
有大神帮忙不,有偿,vx clingme

你发的啥玩意,自己能看懂不

Daniel_Zhang 发表于 2021-3-2 20:01:42

wp231957 发表于 2021-3-2 18:59
你发的啥玩意,自己能看懂不

说实话,我似乎看懂了他说的 line

就是如果两个点 x 或 y 相等,返回相等的那个值

如果x y 不相等,则返回一个 y = kx + b 的一条直线方程

但是 parabola 是啥真没明白{:10_250:}

Hugo888 发表于 2021-3-5 21:39:54

Daniel_Zhang 发表于 2021-3-2 20:01
说实话,我似乎看懂了他说的 line

就是如果两个点 x 或 y 相等,返回相等的那个值


搞定啦已经,谢谢铁子
页: [1]
查看完整版本: 关于求二元一次函数和一元二次函数