TypeError: 'int' object is not callable

前端 未结 6 2158
深忆病人
深忆病人 2020-11-22 14:45

Given the following integers and calculation

from __future__ import division

a = 23
b = 45
c = 16

round((a/b)*0.9*c)

This results in:

6条回答
  •  梦谈多话
    2020-11-22 14:55

    I got the same error (TypeError: 'int' object is not callable)

    def xlim(i,k,s1,s2):
       x=i/(2*k)
       xl=x*(1-s2*x-s1*(1-x)) / (1-s2*x**2-2*s1*x(1-x))
       return xl 
    ... ... ... ... 
    
    >>> xlim(1,100,0,0)
    Traceback (most recent call last):
    File "", line 1, in 
    File "", line 3, in xlim
    TypeError: 'int' object is not callable
    

    after reading this post I realized that I forgot a multiplication sign * so

    def xlim(i,k,s1,s2):
       x=i/(2*k)
       xl=x*(1-s2*x-s1*(1-x)) / (1-s2*x**2-2*s1*x * (1-x))
       return xl 
    
    xlim(1.0,100.0,0.0,0.0)
    0.005
    

    tanks

提交回复
热议问题