189,633 views
18 votes
18 votes
Create a conditional expression that evaluates to string negative if user_val is less than 0, and non-negative otherwise.

User Ltuska
by
2.7k points

1 Answer

24 votes
24 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 David Barlow
by
2.6k points