<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def color_range(color, N=20):
 """ Generates a scale of colours from a base colour Parameters: color : string Color representation in hex N : int number of colours to generate Example: color_range('#ff9933',20) """

    color = normalize(color)
    org = color
    color = hex_to_hsv(color)
    HSV_tuples = [(color[0], x, color[2]) for x in np.arange(0, 1, 2.0 / N)]
    HSV_tuples.extend([(color[0], color[1], x)
                       for x in np.arange(0, 1, 2.0 / N)])
    hex_out = []
    for c in HSV_tuples:
        c = colorsys.hsv_to_rgb(*c)
        c = [int(_ * 255) for _ in c]
        # hex_out.append("#"+"".join([chr(x).encode('hex') for x in c]))
        hex_out.append("#" + "".join(['{0:02x}'.format(x) for x in c]))
    if org not in hex_out:
        hex_out.append(org)
    hex_out.sort()
    return hex_out