Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Boolean Logic | Conditional Statements
Introduction to Python
Section 3. Chapter 3
single

single

bookChallenge: 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!

Task

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 — it should be True if the item is seasonal and its current_stock exceeds high_stock_threshold.
  • Define a boolean variable discount_eligible — it should be True if the item is not selling_well and not on_sale.
  • Define a boolean variable make_discount — it should be True if either overstock_risk or discount_eligible is True.

Output: Print the following line, where the value of make_discount is shown at the end:

Should the item be discounted? True

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 3
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt