Previous

If-Else Statements

6 / 6
Next

Comparing operators that yield Boolean values include:

  • == for equality;
  • != for inequality;
  • < for less than;
  • <= for less than or equal to;
  • > for greater than; and
  • >= for greater than or equal to.

Different Boolean values can be combined with and, or, and not.

a and b True False
True True False
False False False
a or b True False
True True True
False True False
b True False
not b False True
Send

Capstone

Hint
Beginner

Suppose you are developing a finance app to make recommendation about purchasing an item.

Take the following inputs:

  • price: the price of the item (float).
  • current_balance: the amount of money in checking account (float).
  • savingsMade: whether or not the savings goal has been reached this period (y/n).
  • essential: whether or not the item is essential (y/n), e.g., rent or groceries.

The item purchase should be approved if the item is essential, regardless of balance. The item purchase should also be approved if the savings goal was already reached, and there is enough balance.

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

Help
Solve
Reset
Run
Submit
 

Test results

Test result #
Expected output
Your output

Your email has been verified!