+2

what are the different context of != and not operator in real life problems

!= and not operator

4/14/2019 8:53:58 PM

clovert

2 Answers

New Answer

+3

# Specify a language in Relevant Tags to narrow down question scope. I'm proposing an answer in Python because I see in your profile you are learning it. # The `!=` operator is used to compare values of its operands. It returns a boolean state, True when both operands' value equals, False otherwise. a, b = 1, 2 print("a == b ->", a == b) # `==` operator test for equality print("a != b ->", a != b) # `!=` operator test for inequality # The `not` operator returns an inverted logical expression. # It returns True when the operand was False; or return False when the operand was True. # It only accepts one operand to work. # Basically, this is a logical operator, so its operand ideally should be something than can be evaluated as boolean expression. young = True print("young ->", young, "not young ->", not young) if not young: print("You are old") else: print("You are young") Hth, cmiiw

+2

Ipang couldnt have done a better job myself