
Question:
Create a conditional expression that evaluates to string "negative" if user_val is less than 0, and "non-negative" otherwise. Example output when user_val is -9 for the below sample program:
-9 is negative
Code:
user_val = -9
cond_str =0
if user_val<0:
cond_str='negative'
else:
cond_str='non-negative'
print(user_val, 'is', cond_str)
OMG...THANK YOU!
ReplyDeletefor user_val == -9 will give all three correct answer!
ReplyDelete