+ 2

abour boolean logic "not"

why yhe first line of this code is "if not true"??where's the condition?? what's the objective of 'not Ture'? question&codes: What is the result of this code? if not True: print("1") elif not (1 + 1 == 3): print("2") else: print("3")

18th Feb 2020, 5:28 PM
Jon LIU
Jon LIU - avatar
2 Respostas
0
a condition evaluates to True or False. True directly evaluates to True.
18th Feb 2020, 5:53 PM
Oma Falk
Oma Falk - avatar
0
not True = False. So statement inside if condition will not be executed. 2==3 gives False. not False = True. So statement inside elif will be executed.
18th Feb 2020, 6:24 PM
Peter Parker
Peter Parker - avatar