I might be wrong here, but the if statement in the function block should probably be:
if type(Z) == int or type(Z) == float:
[...]
elif type(Z) == str:
[...]
It doesn't matter here if it's not string since it can't be a string if it's an int or float. I don't know Python well, but I'm pretty sure no computer language can compile 'x == 4 or 5' correctly. You need to explicitly say 'x == 4 or x == 5' or it will look at 5 as a condition ("is 5 true or false?"), which should produce some sort of an error.
The reason why it's not printing anything is because you never told it to print something. Return does not print the value. To do what you want it do, you have to use "return print(abs(Z)). What return does is associate a value to the function and ends the function, that's all. It does not print anything.
To see this easily, try running this simple function