Double or Square python function

  function, math, python

I have been trying to create a double or square function on python where the result is to give the user the biggest number back when doubling or squaring. The problem states:

double(x) returns 2 * x square(x) returns x**2 double_or_square(x) returns the larger number between double(x) and square(x)

My code so far has been:

def double(x):
    return (2 * x)
def square(x):
    return (x ** 2)
def double_or_square(x):
    return max(d, q)
d = double
q = square

I keep getting errors, what did I do wrong?

Source: Python Questions

LEAVE A COMMENT