Home > other >  Python how to call a function to do math
Python how to call a function to do math

Time:09-18

Such as I've defined an average function, and then I defined a variance function, and variance functions need to use mean the inside of the solution, but because of different function cannot be directly add and subtract, so what should I do?

CodePudding user response:

No sample?

CodePudding user response:

reference 1st floor chuifengde response:
no sample?




Is I want to make a variance, and then refer to the first mean value function, but have been an error that I mean value function is not int so can't add and subtract, the what to do,,,

CodePudding user response:

Print (res)==& gt; return res

CodePudding user response:

 
Def scheme (li=,2,3,4,5,10,2000,30 [1]) :
Res=sum (li)/len (li)
Print (res)
Return res
Scheme ()

Def varian (li=,2,3,4,5,10,2000,30 [1]) :
Sum2=0
For I in range (len (li) :
Sum1=li [0] - scheme ()
* * 2 +=sum2 sum1
Print (sum2/len (li))
Varian ()

Scheme () function has a return value, in addition to the code posted, don't screenshots, typing also difficult

CodePudding user response:

The
reference 3 floor chuifengde response:
print (res)==& gt; Return res

Thank you,

CodePudding user response:

reference 4 floor weixin_45903952 response:
 
Def scheme (li=,2,3,4,5,10,2000,30 [1]) :
Res=sum (li)/len (li)
Print (res)
Return res
Scheme ()

Def varian (li=,2,3,4,5,10,2000,30 [1]) :
Sum2=0
For I in range (len (li) :
Sum1=li [0] - scheme ()
* * 2 +=sum2 sum1
Print (sum2/len (li))
Varian ()

Scheme () function has a return value, in addition to the code posted, don't screenshots, typing also difficult

Well well thank you
  • Related