+ 1
logic behind this:
if not True: print("1") elif not (1 + 1 == 3): print("2") else: print("3") Can anyone please tell about this code that how it is working? and what is the logic of write "if not True:" this code?
4 odpowiedzi
0
....the keyword not indicates negation... which means
==> the first if statement works if it's true only so the negation of true is false, so it will not be printed...
==> the second statement works if (2 == 3) -->it's false and then negate it....it will be true......print statement works here...
==> the third statement works if first and second if statements aren't true...so the second is true....
+ 3
if not True
It means that it is false.
"if not True" is same as "if False"
hope it will help.
happy coding.
+ 1
if not True is a condition that will never be executed because it evaluates to False
In general, not is a keyword that takes a statement and negates its Boolean value, if True then False, if False then True.