187k views
5 votes
In python, Create a conditional expression that evaluates to string "negative" if user_val is less than 0, and "non-negative" otherwise.

1 Answer

5 votes

I am assuming that user_val is an inputted variable and a whole number (int)...

user_val = int(input("Enter a number: "))

if user_val < 0:

print("negative")

else:

print("non-negative")

User Pranav Kasetti
by
6.4k points