0
Counting
Hello!! please tell me how this output(answer) is 15??? x=5 if(not(x*2==10)): print(x*2) else: print(x*3) tell me below
2 odpowiedzi
+ 4
(5*2 == 10) returns true, but the not inverts it to false. So it moves to the else statement and prints 5*3 which is 15
+ 1
Basically what Aaron Eberhardt said:
The if statement is if(not(x * 2 == 10)):
So first it checks the statement x * 2 == 10 which is True (as x = 5). Then it checks the "not" or the inverse of that statement, which is false. So you are essentially checking if(False): print(x*2). Quite obviously, this will not happen, so instead it moves on the the else statement, which involves printing x * 3, which is 15.