Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Boolean Logic | Conditional Statements
Introduction to Python (copy)
course content

Kursusindhold

Introduction to Python (copy)

Introduction to Python (copy)

1. Getting Started
2. Variables and Types
3. Conditional Statements
4. Other Data Types
5. Loops
6. Functions

book
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!

Opgave

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 as True if the item is seasonal and its current_stock exceeds the high_stock_threshold.
  • Define another boolean variable discount_eligible as True if the item is not selling_well and is not already on_sale.
  • Create a boolean variable make_discount that is True if either overstock_risk or discount_eligible is True.

Output Requirements

  • Print whether the item should be discounted: Should the item be discounted? <make_discount>.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 3
toggle bottom row

book
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!

Opgave

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 as True if the item is seasonal and its current_stock exceeds the high_stock_threshold.
  • Define another boolean variable discount_eligible as True if the item is not selling_well and is not already on_sale.
  • Create a boolean variable make_discount that is True if either overstock_risk or discount_eligible is True.

Output Requirements

  • Print whether the item should be discounted: Should the item be discounted? <make_discount>.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 3
Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Vi beklager, at noget gik galt. Hvad skete der?
some-alt