How to use the "not" in the boolean logic ? | Sololearn: Learn to code for FREE!

+2

How to use the "not" in the boolean logic ?

5/23/2019 8:18:59 AM

Tanmay Maheshwari

10 Answers

New Answer

+3

Use the "not" keyword (not False = True)

+7

https://www.sololearn.com/learn/Python/2279/

+3

If you are using C-like programming languages, use ! (Example: !false = true)

+3

Also correct is A = 1 B = 2 if (not (A == B)): print("A and B are >>not<< equal!") else: print("A and B are equal.") The above syntax is to read more clearly, you need to be aware of closing an opening braces to avoid bracing errors, though, which sometimes may lead in undefined behavior. Sometimes it just leads to more readable code like above, though, imagine a function/program returning either False/True def checkIfTrue: # some code checking something # ... return False Now you can either wrap your lines within a if statement if (checkIfTrue): # continue with the program else: exit or just save one indentation level if (not (checkIfTrue)): exit # continue with the program

+2

Maine function of not is to reverse the output. If your result is true then not ture will give output false

+1

In python how to use it.?

+1

The not operator is an inverter meaning the condition followed by the operator is inverted Eg Print (not True) This will return false And since it is used to invert, its an unary operator, i.e it takes only one condition

+1

You can use 'not' in the boolean logic just like '!= True' meaning if the statement is false.

+1

+1

https://code.sololearn.com/W0uI58Z0RPnp/?ref=app