セクション 3. 章 3
single
Challenge: Boolean Logic
メニューを表示するにはスワイプしてください
Ready to put everything you've learned into practice? This challenge will require you to use the and, or, and not operators as well as boolean comparison operators to manage a complex scenario for a grocery store.
Let's dive in!
タスク
スワイプしてコーディングを開始
Determine whether a grocery item should be discounted based on its seasonal status, stock level, and sales performance.
- Define a boolean variable
overstock_riskasTrueif the item isseasonaland itscurrent_stockexceeds thehigh_stock_threshold. - Define another boolean variable
discount_eligibleasTrueif the item isnotselling_welland isnotalreadyon_sale. - Create a boolean variable
make_discountthat isTrueif eitheroverstock_riskordiscount_eligibleisTrue.
Output Requirements
- Print whether the item should be discounted:
Should the item be discounted? <make_discount>.
Requirements checklist
- Check that the value of overstock_risk is True if seasonal is True and current_stock is greater than high_stock_threshold.
- Check that the value of discount_eligible is True if selling_well is False and on_sale is False.
- Check that make_discount is True if either overstock_risk or discount_eligible is True.
- Check that the printed output contains "Should the item be discounted?" followed by the value of make_discount.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 3. 章 3
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください