if logical-expression: statement statementIn our case we also use else which is used if the logical expression fails:
if logical-expression: statement statement else: statementalso note the indentation. The statements need to be indented either 4 spaces or simply hit Tab from you key board. A logical expression is one that evaluates to true or false. A nonzero numeric value is considered to be true, and a zero value, false. If the expression is true, the indented statement or statements are executed. Otherwise it is skipped. Here we are checking whether d is less than zero. We use the relational "is less than" < operator. comparison operators were introduced in the last class. They are attached below.
if (condition1 and conditoin2): statementfor example
if( d<0 and a==1): print("I found it")
> Greater Than < Less Than == Equal != Not Equal >= Greater than or Equal to <= Less than or EqualLogical operators
and (&) True if both operands are true or (|) True if either operands are truestart an emacs editor and create the file log-ope.py to your directory and run it.