22.7k views
2 votes
Create a conditional expression that evaluates to string negative if user_val is less than 0, and non-negative otherwise.

1 Answer

5 votes

Answer: I am supposed to write a few lines of code to create a conditional expression (ternary operation) that evaluates to string "negative" if user_val is less than 0 and "non-negative" if 0 or greater than 0.

The code I currently have prints "negative" when the number is less than zero but when a number 0 or greater is assigned to user_val it doesn't print "non-negative."

User Coolie
by
3.4k points