how to make positive number negative in 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: convert negative to positive in python
>>> n = -42
>>> -n
42
>>> abs(n)
42
>>> abs(-5.05)
5.05
Example 3: how to make a program that identifies positives and negatives in python
number = float(input(" Please Enter any Numeric Value : "))
if(number > 0):
print("{0} is a Positive Number".format(number))
elif(number < 0):
print("{0} is a Negative Number".format(number))
else:
print("You have entered Zero")