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!
Swipe to start coding
Determine whether a grocery item should be discounted based on its seasonal status, stock level, and sales performance.
- Define a boolean variable
overstock_risk
asTrue
if the item isseasonal
and itscurrent_stock
exceeds thehigh_stock_threshold
. - Define another boolean variable
discount_eligible
asTrue
if the item isnot
selling_well
and isnot
alreadyon_sale
. - Create a boolean variable
make_discount
that isTrue
if eitheroverstock_risk
ordiscount_eligible
isTrue
.
Output Requirements
- Print whether the item should be discounted:
Should the item be discounted? <make_discount>
.
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Summarize this chapter
Explain the code in file
Explain why file doesn't solve the task
Awesome!
Completion rate improved to 2.17
Challenge: Boolean Logic
Swipe to show menu
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!
Swipe to start coding
Determine whether a grocery item should be discounted based on its seasonal status, stock level, and sales performance.
- Define a boolean variable
overstock_risk
asTrue
if the item isseasonal
and itscurrent_stock
exceeds thehigh_stock_threshold
. - Define another boolean variable
discount_eligible
asTrue
if the item isnot
selling_well
and isnot
alreadyon_sale
. - Create a boolean variable
make_discount
that isTrue
if eitheroverstock_risk
ordiscount_eligible
isTrue
.
Output Requirements
- Print whether the item should be discounted:
Should the item be discounted? <make_discount>
.
Solution
Thanks for your feedback!
Awesome!
Completion rate improved to 2.17single