Python Function Code Error

前端 未结 2 1284
广开言路
广开言路 2021-01-25 16:05

I am trying to build a code that spits out y given f(x). Apparently, mine isn\'t working. Can you please help?

def f(n):
    \'\'\'The Function\'\'\'
    return          


        
2条回答
  •  遥遥无期
    2021-01-25 16:45

    Use this:

    return (-5*(n**5))+(69.0*(n**2))-47
    

    The algebraic notation you are using i.e. omitting the '*' sign causes python to think that you are trying to make a function call:

    69.0(n**2)  # python thinks 69.0 is a function name and n**2 is the parameter of this call
    

    That is why the '*' operator is necessary, between two operands.

提交回复
热议问题