TypeError:“float”对象不可调用/未知错误/无表达式

2024-09-24 10:23:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用梯形rul数值积分正态分布函数:

import math as m
def f(x):
    N(x)
    return x

def N(x):
    x=((2*m.pi)**-(1/2))*m.e(-(1/2)*x**2)
    return x

def trap(a, b, n):
    h = float(b - a) / n
    t = 0.0
    for i in range(1, n):
        t += f(a + i*h)
    t += (f(a)+f(b))/2.0
    return t * h

n=int(raw_input("the value of n is:"))
a=int(raw_input("the value of a is:"))
b=int(raw_input("the value of b is:"))


print(trap(a,b,n))

但是,当我试着打电话

^{pr2}$

我在第15行N中得到以下错误:

TypeError: 'float' object is not callable


Tags: oftheinputrawreturnisvaluedef