从其他函数调用函数

2024-04-24 23:13:07 发布

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

我很难让这个程序正常工作,因为输入是TypeError: 'int' object is not callable

#!/usr/bin/python3



def displaymenu():

    input32=int(input("1)  Run experiment\n2) Exit"))
    return input32  
def cal1(we,woc,wa):

    wala=we*woc(wa-woc)
    return wala

def cal2(wo,woh):

    wolo=24*wo*woh*wa
    return wolo

def cal3(wa,woc):

    wele=wa**2+woc(wa-woc)
    return wele

def beamere(wala,wolo,wele):

    y=(wala/wolo)*wele
    return y

input32 = displaymenu()
while input32 is not 2:

    if input32 == 1:
        we= int(input("enter your width"))
        wo= int(input("enter what ever this is"))
        woh=int(input("enter this thing"))
        wa= int(input("i really should stop calling my varibles random sylibles"))
        woc=int(input("enter your woc"))
        wala  =  cal1(we,woc,wa)
        wolo  =  cal2(wo,woh)
        wele  =  cal3(wa,woc)
        y     =  beamere(wala,wolo,wele)
        print(y)



    elif input32 == 2:


        print("learn english")
        break
    else:
        input32 = displaymenu()

Tags: inputreturnisdefintweenterwa
2条回答

这是由于您的cal1cal3: 在执行wala=we*woc(wa-woc)时,您告诉python使用woc作为函数,您可能打算使用wala=we*woc*(wa-woc)woc乘以(wa-woc)。第二个函数也是如此

以下是您的函数的外观:

def cal1(we,woc,wa):

    wala=we*woc(wa-woc)
    return wala

def cal3(wa,woc):

    wele=wa**2+woc(wa-woc)
    return wele

在函数def cal1中修改行 从

wele=wa**2+woc(wa-woc)

wele=wa**2+woc*(wa-woc)

woc(wa woc)—>;指示参数为“wa woc”的woc函数调用

相关问题 更多 >