what is the syntax error in this code in python? -
i'm new in programming , in python , watching lecture , wanted create simple functions lecturer in video , design 3 functions , addition , mean , mean_addition show below , addition add 2 numbers , mean function calculate mean of 2 numbers mean_addition adds mean , addition of 2 numbers
i writed code , run program had told me there syntax error , checked on , on again can't decide wrong
the code of simple programme :
def addition(float1,float2): '''(float,float)-> float return addition of float1 , float2 . >>> addition(2,3) 5.0 >>>addition(4,6) 10.0 ''' return float1+float2 def mean(x , y ): ''' (number,number)-> float return mean of 2 numbers , x , y . >>> mean(2,4) 3.0 >>> mean(9,2) 5.5 ''' return addition(x,y)/ 2 def mean_addition(t,s): ''' (float,float)->float return mean of 2 numbers plus addition of 2 numbers >>> mean_addition(1,2) 4.5 >>> mean_addition(4,5) 13.5 ''' return addition(t,s) + mean(t,s) one thing want mention error in third function mean_addition because when deleted part worked !
the problem , when choose run modulo says "expected indented block"
so syntax error have made ?
thanks.
note : explore question in future , syntax error made ( learned answer ) wrote
def mean_addition(t,s): ''' (float,float)->float but shouldn't put " ''' " under "def" , should make space under "def" right code
def mean_addition(t,s): ''' (float,float)->float
def addition(float1,float2): '''(float,float)-> float return addition of float1 , float2 . >>> addition(2,3) 5.0 >>>addition(4,6) 10.0 ''' return float1+float2 def mean(x , y ): ''' (number,number)-> float return mean of 2 numbers , x , y . >>> mean(2,4) 3.0 >>> mean(9,2) 5.5 ''' return addition(x,y)/ 2 def mean_addition(t,s): ''' <----- error here (float,float)->float return mean of 2 numbers plus addition of 2 numbers >>> mean_addition(1,2) 4.5 >>> mean_addition(4,5) 13.5 ''' return addition(t,s) + mean(t,s)
Comments
Post a Comment