+ 4

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

23rd May 2019, 8:18 AM
Tanmay Maheshwari
Tanmay Maheshwari - avatar
15 ответов
+ 6
Use the "not" keyword (not False = True)
23rd May 2019, 8:22 AM
Airree
Airree - avatar
+ 4
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
20th May 2021, 11:23 AM
Niederkofler Martin
+ 3
If you are using C-like programming languages, use ! (Example: !false = true)
23rd May 2019, 8:20 AM
Airree
Airree - avatar
+ 2
Hh
3rd Jul 2021, 3:22 PM
Hamza Rahali
Hamza Rahali - avatar
+ 2
Maine function of not is to reverse the output. If your result is true then not ture will give output false
29th Sep 2021, 4:19 PM
Rishav Kumar
Rishav Kumar - avatar
22nd Nov 2021, 7:08 PM
✓`•°`™AnOnimus™`°•`✓ فايز الله‎
✓`•°`™AnOnimus™`°•`✓   فايز الله‎ - avatar
+ 1
In python how to use it.?
23rd May 2019, 8:21 AM
Tanmay Maheshwari
Tanmay Maheshwari - avatar
+ 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
12th Apr 2021, 7:26 AM
shubham damania
shubham damania - avatar
+ 1
You can use 'not' in the boolean logic just like '!= True' meaning if the statement is false.
5th May 2021, 2:26 PM
Lemi Elias
Lemi Elias - avatar
+ 1
you use not for not intend of the list
12th Apr 2022, 1:06 PM
Jena
0
I know that A != B A =1 B=2 not (A==B) is the same as A ! =B The answer is the same, True
30th Jul 2022, 10:12 AM
Israel Mutebi
0
You can use 'not' in the boolean logic just like '!= True' meaning if the statement is false.
23rd Aug 2022, 4:37 PM
Shivansh Srivastava
Shivansh Srivastava - avatar
0
There is a short way: Use the ! Symbol instead of using Not, Like: If (2 != 2): Or If (not ( 2 == 2)):
24th Sep 2022, 8:41 AM
Yousef Yousefzai