M8) Order status
A web shop shows each order’s status from 2 facts: whether it has been paid, and whether it has been shipped. Table 1 gives the required status for each combination. An order that was shipped without being paid points to a mistake in the warehouse, so staff must check it.
| Paid | Shipped | Status |
|---|---|---|
False |
False |
Awaiting payment |
True |
False |
Packing |
True |
True |
On its way |
False |
True |
Check order |
A programmer wrote the match statement in Listing 1. The pattern _ matches any value.
match statement for the order status (Question 1).
Which statement about Listing 1 is true?
order_status(False, True)returns"Check order", because that case matches the inputs exactly.- The last case can never run, so
assert order_status(False, True) == "Check order"fails. - Python refuses to run the function, because 2 cases match the same inputs.
order_status(True, True)returns"Awaiting payment", because_matches any value.