Create an interface that fits the XKCD Types colors.rgb("blue") yields "#0000FF". colors.rgb("yellowish blue") yields NaN. colors.sort() yields "rainbow"


Using the rules set out in the image and its title text (quoted here), create a program that accepts all the given input and displays the appropriate output.


Input can be taken with stdin or nearest equivalent. There should be a line like [n]&gt; on which to type it, and n increases by 1 each command. It should start at 1.
The result should be displayed using stdout or nearest equivalent. There should be a =&gt; on each line of output.


All 13 conditions, plus the 3 in the title (quoted) must work.

This is code golf, so shortest answer wins.
Python 3, 700 698 697 689 683 639 611

Tabs as indentation.

from ast import*
E=literal_eval
O='=&gt;%s\n'
P=print
I=int
def Q(a):P(O%a)
def W(a):Q('"%s"'%str(a))
def gb(a):W(_ if'y'in a else'#0000FF')
def t():W('rainbow')
def FLOOR(n):P(O%'|'*3+(O%'|{:_^10}').format(n))
def RANGE(*a):Q([('"','!',' ','!','"'),(1,4,3,4,5)][len(a)])
c=0
while 1:
    try:
        c+=1;A,*B=input('[%d]&gt;'%c).split('+')
        if not A:W(c+I(B[0]))
        elif A=='""':Q("'\"+\"'")
        elif B:
            A=E(A);B=E(B[0])
            if A==B:Q('DONE')
            elif type(A)==list:Q(A[-1]==B-1)
            elif type(B)==list:W([I(A)])
            else:W(A+I(B))
        else:eval(A.lstrip('colrs.'))
    except:Q('Na'+['N','P','N.%s13'%('0'*13)][('-'in A)+len(B)])


Since this uses a bare Except you can't Ctrl-C it. Ctrl-Z and kill %% work though

Some of the conditions are generalized and others will only work with exact input.


A+"B" will work with any A and B not just when A == B
"A"+[] will work for any A that can be converted to an int (Includes hex and binary strings e.g 0xff and 0b01010)
(A/0) will work for any A, Eval Causes DivideByZeroError which is handled in the except
(A/0)+B will work with any A or B. literal_eval (E) raises an error.
""+"" only works for the + sign. Anything else will print NaN, NaP or NaN.00...
[A, B, C]+D works by checking that D == C+1 so will work for any length of list and any numbers.
^^
2/(2-(3/2+1/2)), Anything that fails to parse that has - with a + somewhere after it will output NaN.000...13
RANGE(" ") Hardcoded
+A will work for any A. Ouputs "current_line_number+A"
A+A works for any A as long as they are the same and are bulitin python types
RANGE(1,5) Hardcoded.
FLOOR(A) works for any A.
colors.rgb("blue") The lstrip in eval turns this in gb("blue") which has a hardcoded response.
colors.rgb("yellowish blue") The lstrip in eval turns this in gb("yellowish blue") which attempts to use a non existent variable if y is present in the arguement causing an error which the except turns into NaN
colors.sort() The lstrip turns this into t() which has a hardcoded response.






Brainsteel pointed out an error in my assumption for rule 10.