[Tutor] revisiting a puzzle about -3**2 vs (-3)**2

D Wyatt fiberfolly at gmail.com
Wed Aug 12 18:07:01 CEST 2015


so I 'get' that -5**2 = -25 and (-5)**2 is 25, BUT if you write a function

def sq(x):
  """ Output: sq returns the square of its input
      input x: a number (int or float)
  """
  return x**2

and pass it a negative number it handles it as though the argument is
in parentheses.

I find this confusing.  Can someone explain?

Also, can someone please take me off moderated?

thanks in advance.
-- 
Deb Wyatt in WA


More information about the Tutor mailing list