Aug-20-2019, 02:27 AM
(This post was last modified: Aug-20-2019, 02:52 AM by majorjohnusa.)
Hi all, I have a rookie question about True and False.
This code will have a result of 1.
But I don't understand: where does this True come from? I did not input any value or give any condition such as (1+1==2). To me this looks more like a "null" because there was nothing there.
Thanks.
I think I figured out, an if statement is run once if its condition evaluates to True. In this case, it is stated as True in the statement.
This code will have a result of 1.
if True: print("1") elif True: print ("2") else: print("3")On the other hand, the following code will have a result of 2.
if not True: print("1") elif not False: print ("2") else: print("3")Based on the code, I realized that the first if statement
if True: print("1")resulted as a True. And it appears to me that all statement is by default True unless otherwise specified as False, for example: (1+1==3).
But I don't understand: where does this True come from? I did not input any value or give any condition such as (1+1==2). To me this looks more like a "null" because there was nothing there.
Thanks.
I think I figured out, an if statement is run once if its condition evaluates to True. In this case, it is stated as True in the statement.