This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revisionBoth sides next revision |
184_notes:if [2022/04/20 15:24] – woodsna1 | 184_notes:if [2022/05/06 22:02] – woodsna1 |
---|
quotient = numerator/denominator | quotient = numerator/denominator |
</code> | </code> |
Everything that follows the word "if" is called the conditional. The code within an if statement will only execute if the conditional evaluates to True. In this case, we only compute the quotient for a nonzero denominator. You can read if statements out loud to understand what they're doing. In the above example, the if statement could be read as "if the denominator is not equal to 0, divide". | Everything that follows the word "if" is called the conditional. The code within an if statement (the indented code) will only execute if the conditional evaluates to True. In this case, we only compute the quotient for a nonzero denominator. You can read if statements out loud to understand what they're doing. In the above example, the if statement could be read as "if the denominator is not equal to 0, divide". |
| |
===== Else Clauses ===== | ===== Else Clauses ===== |