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?
5 Antworten
+ 3
2 is result
+ 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.
+ 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
+ 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
+ 1
This stat 1+1 == 3 is false and the inverse it is true
The response is 2 because the condition is right