Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Sales and Shipments | Loops
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Introduction to Python

bookChallenge: Sales and Shipments

In this challenge, you'll manage the daily stock levels of essential grocery store products over a week. By utilizing the range() function in conjunction with the len() function, you'll simulate sales impacts on inventory.

Task

Swipe to start coding

Update the stock levels using one loop.

  • Use a for loop with index iteration (range) to go through products.

  • For each product, subtract the sold amount from units_sold using the same index:

    • products[i][1] = products[i][1] - units_sold[i]

At the end, print exactly: Final stock levels: <products>

Expected final products: [['Apples', 7], ['Bananas', 3]]

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 7
single

single

Ask AI

expand

Ask AI

ChatGPT

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

close

bookChallenge: Sales and Shipments

Swipe to show menu

In this challenge, you'll manage the daily stock levels of essential grocery store products over a week. By utilizing the range() function in conjunction with the len() function, you'll simulate sales impacts on inventory.

Task

Swipe to start coding

Update the stock levels using one loop.

  • Use a for loop with index iteration (range) to go through products.

  • For each product, subtract the sold amount from units_sold using the same index:

    • products[i][1] = products[i][1] - units_sold[i]

At the end, print exactly: Final stock levels: <products>

Expected final products: [['Apples', 7], ['Bananas', 3]]

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Β 7
single

single

some-alt