Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Automating Stock Control | Loops
Introduction to Python

bookChallenge: Automating Stock Control

Task

Swipe to start coding

You are restocking a grocery store before opening.

For each item in inventory, keep adding the restock amount until the stock reaches the target stock level.

Rules:

  1. Print Restocking started before you begin.

  2. Use a for loop to go through each item in inventory.

    • For each item, print: Restocking <item name>
  3. Use a while loop to restock that item until:

    • current stock is at least the target stock level
    • Each time the loop runs, increase stock by the restock amount
  4. Update the current stock inside the dictionary after restocking.

  5. Print Restocking completed after all items are processed.

Do not print any extra details about the stock numbers. Only print the required lines.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 9
single

single

Ask AI

expand

Ask AI

ChatGPT

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

close

bookChallenge: Automating Stock Control

Swipe to show menu

Task

Swipe to start coding

You are restocking a grocery store before opening.

For each item in inventory, keep adding the restock amount until the stock reaches the target stock level.

Rules:

  1. Print Restocking started before you begin.

  2. Use a for loop to go through each item in inventory.

    • For each item, print: Restocking <item name>
  3. Use a while loop to restock that item until:

    • current stock is at least the target stock level
    • Each time the loop runs, increase stock by the restock amount
  4. Update the current stock inside the dictionary after restocking.

  5. Print Restocking completed after all items are processed.

Do not print any extra details about the stock numbers. Only print the required lines.

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Β 5. ChapterΒ 9
single

single

some-alt