negative numbers to positive python code example
Example 1: get random number positive or negative python
import random
return 1 if random.random() < 0.5 else -1
Example 2: python convert any number in positive
a = abs(-1)
return a
#returns 1
import random
return 1 if random.random() < 0.5 else -1
a = abs(-1)
return a
#returns 1