Solution:
The problem happened with the very first line of your script. In your case, you are taking input as a string, because you didn't initialize n as an integer type. Then, in the next line you expecting the input as an integer value. That is really absurd. To avoid the TypeError take the input as an integer and stored to your variable n and then proceed on.
n = int(input('Input a random number: '))
if n >=0:
print(n)
else:
print(-n)
Now, the script is looking good and should print as you are expecting.
Thanks.