Create a conditional expression that evaluates to string "negative" if user_val is less than 0, and "non-negative" otherwise.

Sample output with input: -9
-9 is negative

here is the code:
user_val = int(input())

cond_str = 'negative' if user_val < 0 else cond_str

print(user_val, 'is', cond_str)

Answer :

MrRoyal

Answer:

The modified program is as follows:

user_val = int(input())

cond_str = 'non-negative'  

if user_val < 0:

   cond_str = 'negative'  

print(user_val, 'is', cond_str)

Explanation:

This gets input for user_val

user_val = int(input())

This initializes cond_str to 'non-negative'

cond_str = 'non-negative'

If user_val is less than 0

if user_val < 0:

cond_str is updated to 'negative'

   cond_str = 'negative'  

This prints the required output

print(user_val, 'is', cond_str)