Print Biggest-Smallest in Python 3.4 -


i learning python , udacity course love, "intro computer science though python". attempt here:

def biggest(x,y,z):     max = x     if y>max:         max = y     if  z>max:         max = z     return max  def smallest(x,y,z):     min = x     if y<min:         min = y         if z<min:             min = z     return min  def set_range(x,y,z):     result==biggest-smallest     return result   print set_range(10, 4, 7) 

i error message:

"line 18, in set_range     result=biggest-smallest typeerror: unsupported operand type(s) -: 'function' , 'function'" 

why getting error?

i have no ideas why have same functions twice need call functions, pass parameters , use = assigning not == equality:

def biggest(x, y, z):     mx = x      if y > mx:         mx = y     if z > mx:         mx = z     return mx      def smallest(x, y, z):     mn = x     if y < mn:         mn = y     if z < mn:         mn = z     return mn   def set_range(x, y, z):     # use  "=" assignment not  "==" equality     result = biggest(x, y, z) - smallest(x, y, z)     return result  print set_range(10, 4, 7) 

== used want test if 2 values equal ie 1 == 1 , single = when want assign name variable i.e foo = 1.

also best avoid shadowing builtin max , min functions changed names in functions.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -