How is code executed in the computer
I mean how the interpreter executes a code without translating it into machine code

TL;DR It's the interpreter's (machine) code that executes your program's code.
To explain it better, consider these lines taken from your example:
def sub(a,b)
    print(a-b)

I think you got this point wrong: when you write x-y in an interpreted programming language it's because you want to know the result (for example to save it into a variable) rather than to be printed. Also, the variables of the interpreter are not mixed with the ones of the interpreted programs: for example the variables x and y could have some meaning for the interpreter and another meaning for the final program. Usually the interpreter does not make any assumption on the program's variable, it just stores them into a &quot;memory&quot; which is just a set of pairs &lt;variable_name, value&gt;.
So, when there is an instruction like z = x-y in your program, the interpreter does the following:

look into the memory, retrieve the current value for x
look into the memory, retrieve the current value for y
compute x-y (call the result R).
set the value for z to be R in the memory.

Point 3. in the list above is crucial. If this was a real interpreter, it would not be a Python program but a compiled one, thus the implementation of point 3. would be a bunch of machine code that eventually contains a sub machine instruction, or some other sequence of machine instructions that together implement the subtraction.
So every instruction of every language is executed as machine code eventually:

in the compiled languages the higher level instructions are translated into machine code;
in the interpreted languages it's the interpreter's machine code to be executed.

Read the last paragraph again.
Actually you could write an interpreter using Python, but in this case it's the Python interpreter's machine code to be executed. Or it could have been any chain of pairs &lt;interpreted language $L_i$, interpreter for $L_i$&gt;, the point is that the last interpreter must be compiled, and thus at the very last it's just machine code to be executed because that is the only languages that the processor understands