+ 1

Not Output in the function

I'm create a code, his coordinates turn into degrees. If x smaller then 0, function haven't output def mod(n): if n < 0: n * -1 return(n) def rad(x,y): state = [] if mod(x) >= mod(y) and x>=0 and y>=0: state = [(y/x)*45,"N"] return(state) elif mod(x) >= mod(y) and x>=0 and y<=0: state = [(y/x)*45,"N"] return(state) elif mod(x) >= mod(y) and x<=0 and y>=0: state = [(y/x)*45,"S"] return(state) print(rad(-10,5))

6th Feb 2019, 8:36 AM
SomChack
SomChack - avatar
3 Answers
+ 5
n * -1 doesn't do anything. You probably need to change it to n *= -1 (or you can use abs(n) as well).
6th Feb 2019, 9:28 AM
Anna
Anna - avatar
+ 4
There is a __builtin__ function "abs" which would do the same work than "mod", if you didn't already know. I am testing your code.
6th Feb 2019, 9:27 AM
Seb TheS
Seb TheS - avatar
+ 2
Thanks You
6th Feb 2019, 9:29 AM
SomChack
SomChack - avatar