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_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>.
Løsning
Takk for tilbakemeldingene dine!
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Oppsummer dette kapittelet
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 2.17
Challenge: Boolean Logic
Sveip for å vise menyen
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_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>.
Løsning
Takk for tilbakemeldingene dine!
single