Question:
I want to be able to have my code see if it is a positive or a negative number and if it’s a positive number I want it to print something but then if it’s a negative number I want it to print something else. Any ideas? Repl link: https://replit.com/@Chandler0Bing/Watching-Your-Calories#main.py
0. is actually positive because small positive numbers round down to it, while small negative numbers (like -1e-999) round down to -0., which is useful e.g. when rounding celsius temperatures so you know whether it’s below freezing.
import math
print(
"negative" if math.copysign(1, float(input("Enter a number"))) > 0 else "positive"
)