+ 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?

4th Jun 2020, 11:40 AM
Anil Gurjar
Anil Gurjar - avatar
3 Respostas
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....
4th Jun 2020, 11:56 AM
Nahoma
Nahoma - avatar
+ 3
if not True It means that it is false. "if not True" is same as "if False" hope it will help. happy coding.
4th Jun 2020, 11:42 AM
ツSampriya😘ツ
ツSampriya😘ツ - avatar
+ 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.
4th Jun 2020, 11:59 AM
Ali Abdelhady
Ali Abdelhady - avatar