If-Else Statements

4 / 4

Besides Boolean and, there is also Boolean or and not. Only one of a and b must be true in order for a or b to be true. So the truth table of Boolean or is as follows:

a\b True False
True True True
False True False
The `not` operation works on only one Boolean expression, and `not b` will be the opposite value of `b`. The truth table for `not` is as follows:
b True False
not b False True

Other Boolean operations

You are developing a finance app to help users decide whether or not to purchase an item.

Take the following Boolean inputs:

  • emptySavings: the user's savings account is almost empty.
  • essential: the purchase is essential (e.g., groceries, rent).
  • onSale: the item is available on a discounted price. A purchase should be approved if the item is essential, or if the user has some savings left and the item is on sale.

Print approved or denied based on whether a purchase is approved.

Congratulations!

You passed the !

Welcome!

Would you like a guided tour on how to use Vibewise?

Your email has been verified!