0

boolean not

What is the result of this code? if not True: print("1") elif not (1 + 1 == 3): print("2") else: print("3") what is the logic used here? How does it works?

15th Apr 2020, 2:35 PM
PRIYANKA K
PRIYANKA K - avatar
5 odpowiedzi
+ 3
2 is result
15th Apr 2020, 2:41 PM
Raj Kalash Tiwari
Raj Kalash Tiwari - avatar
+ 2
not true means False not ( 1+1 == 3) means True because 1+1 = 3 is false so not (False) is True if False: print("1") elif True: print("2") else: print("3") So the code will print 2 cause it's true, it will execute the code. If it's false, it won't execute the code.
15th Apr 2020, 2:42 PM
Oussama Ben Sassi
Oussama Ben Sassi - avatar
+ 2
It works as follow If not true => means if false ( failed ) Then else if not(1+1==3)= elif not (2==3) elif not (0) = elif 1 Then it is satisfied just it prints 2
15th Apr 2020, 2:44 PM
Raj Kalash Tiwari
Raj Kalash Tiwari - avatar
+ 1
not true is false so if statement would'nt execte. Than not(1+1==3) is true so second elif statment execute and answer is 2
15th Apr 2020, 2:42 PM
Muhammad Bilal
Muhammad Bilal - avatar
+ 1
This stat 1+1 == 3 is false and the inverse it is true The response is 2 because the condition is right
15th Apr 2020, 8:31 PM
HADÈS
HADÈS - avatar