从其他函数调用函数

时间:2018-05-17 07:26:42

标签: python python-3.x

我在制作此程序时遇到问题,只需在输入#!/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() 后返回

.CustomGridHeader {
     width: 100%;
}

@media (min-width:300px){
.Grid{
    width:50%;
    float:left;
 }

 .item
 {
    width:50%;
    float:left;
    /*border:1px solid black;*/
 }
}
 @media (min-width:50px) and (max-width:300px) {
   .Grid {
      width: 100%;
      float: none;
   }
   .item
 {
    width:50%;
    float:left;
    /*border:1px solid black;*/
 }
}

2 个答案:

答案 0 :(得分:0)

这是由于您的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

答案 1 :(得分:0)

在函数 def cal1 中修改该行 来自

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

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

WOC(WA-WOC) - >表示带有参数' wa-woc'

的woc函数调用