Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Solo Coding Capstone | Loops
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: Solo Coding Capstone

In this chapter, it's time to challenge your coding abilities. You'll be presented with a task, but this time it's up to you to determine the solution. You can use any syntax and techniques you've learned so far, but it's highly recommended to use loops and conditional statements to make your code flexible and adaptable to different inputs and scenarios.

Opgave

Swipe to start coding

Evaluate items in an inventory dictionary and print appropriate messages based on their stock levels and pricing.

  • Loop through each item in the inventory dictionary.
  • For each item:
    • If stock is below 30, print that it needs restocking.
    • If stock is above 100, print that it should be sold at the discounted price.
    • If stock is 30 to 100, print that it should be sold at the regular price.

Output Requirements

Use the following template print statements exactly:

  • For restocking:
    f"{item} need restocking."
  • For discounted price:
    f"{item} should be sold at the discounted price of {discounted_price}."
  • For regular price:
    f"{item} should be sold at the regular price of {regular_price}."

Note

Follow the print formats exactly to ensure your solution is accepted.

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 5. Kapitel 8
toggle bottom row

book
Challenge: Solo Coding Capstone

In this chapter, it's time to challenge your coding abilities. You'll be presented with a task, but this time it's up to you to determine the solution. You can use any syntax and techniques you've learned so far, but it's highly recommended to use loops and conditional statements to make your code flexible and adaptable to different inputs and scenarios.

Opgave

Swipe to start coding

Evaluate items in an inventory dictionary and print appropriate messages based on their stock levels and pricing.

  • Loop through each item in the inventory dictionary.
  • For each item:
    • If stock is below 30, print that it needs restocking.
    • If stock is above 100, print that it should be sold at the discounted price.
    • If stock is 30 to 100, print that it should be sold at the regular price.

Output Requirements

Use the following template print statements exactly:

  • For restocking:
    f"{item} need restocking."
  • For discounted price:
    f"{item} should be sold at the discounted price of {discounted_price}."
  • For regular price:
    f"{item} should be sold at the regular price of {regular_price}."

Note

Follow the print formats exactly to ensure your solution is accepted.

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 5. Kapitel 8
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