TypeError: a float is required

前端 未结 1 826
误落风尘
误落风尘 2021-01-05 05:31

Can\'t post image, so: a[i]={(-1)^(i+1)*sin(x)*ln(x)}/{i^2*(i+1)!}

The task:
Need to find a1,a2,...,an.
n is natural and it\'s given.

Th

相关标签:
1条回答
  • 2021-01-05 06:02

    Seems like you're using Python 3.x version. The result of an input call is a string taken from keyboard, which you pass to a math.sin(...) function. float(x) converts x to float but does not store the converted value anywhere, so change:

    float(x)
    

    to:

    x = float(x)
    

    to get right behaviour of your code.

    0 讨论(0)
提交回复
热议问题