Check number is positive or not using conditional operators in Python Programming

Conditional expressions in Python

Ternary operators, also known as conditional expressions, are operators that evaluate based on whether a condition is true or false. It was added to Python in the 2.5th edition.
This only allows testing a condition in a single line, replacing multi-codes if-and makes the code compact.


[on_true] if [expression] else [on_false] 
Program to Check number is positive or Not using conditional Operator
n=int(input("Enter the number:-"))
print("Positive number"if n>0 else "Negative number")
shivam@coder:~/Desktop$ python
Enter the number:--2
Negative number