 This is the given code if not True: print("1") elif not(1+1==3): print("2") else print("3") I know the answer is 2 but what does the first print("1") do? | Sololearn: Learn to code for FREE!

+11

# This is the given code if not True: print("1") elif not(1+1==3): print("2") else print("3") I know the answer is 2 but what does the first print("1") do?

+27

if 1st line makes no sense to you: press(^)

+23

For the first part, how does it know if not True is true or false?

+18

if not True: print("1") #prints 1 if not True is True elif not(1+1==3): print("2") #prints 2 if 1+1 is not 3 else: print("3") #else prints 3

+15

In basic english: If true is not equal to true, print 1 Else, if 1 + 1 is not equal to 3, print 2 Else, print 3

+12

What people seem to forget is how the "if statement" works. In other words, the expression for the "if statement" needs to be evaluated as 'True' in order to continue with the statement, otherwise it moves on to the next part of the code. From the example, if not True: # if False => skips the next statement print("1") elif not (1 + 1 == 3): # else if True => continues with the statement print("2") else: # since the previous statement was true, '2' is printed and the next statement is skipped print("3")

+8

When nothing is declared, it's presumend as True. So since nothing was declared on line 1; the "thing" your comparing is True. Hence True not True? The answer is False. So we move to line 3.

+7

if not True: # not True is False print("1") elif not(1+1==3): # not(1+1==3) is True print("2") else print("3") # the previous condition is fulfilled, therefore, this not reaches evaluated

+6

Explanation: First suite: If statement is always true, so “1” will not be printed because of “not operator” (if not True = False). Second suite: (1+1 == 3) is false but there is a “not operator” so it will become true. It will print “2”. Third suite: Will not be read since the second suite is already true.

+2

I also don't understand how d answer is 2...

+1

if/elif statements are only executed if the condition is True. Since the first line is not True, it is not executed. Hence, moving on to the next statement.

+1

For the thing, dont think to hard about it. It says if not true print 1. Not True is False, so you don't even have to look at it, because it is false.

+1

it does not make any sense :) the answer is 2 tho

0

the second logic is to be applied as the question ends there the third logic is an extra one.

0

i still don't get the first line. what does if not true print 1 means? I what case would the output be "1"

0

I want to face challenges regarding HTML and CSS. is there any Challenger

0

if not False: print(“1”) output:1

0

The answer is 2 if not True: print("1") elif not (1 + 1 == 3): print("2") else: print("3")

0

If not true may acts as if false so each and every time it will check elif part