セクション 5. 章 5
single
Challenge: 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.
タスク
スワイプしてコーディングを開始
Update product stock levels based on sales and shipments using loops.
- Use a
forloop with index iteration to go through theproductslist.- For each product subtract the number of units sold (
units_sold) from theproductsstock.
- For each product subtract the number of units sold (
- Use a second
forloop (also with index iteration) to go throughproductsagain.- Add the corresponding value from
shipment_receivedto update the stock.
- Add the corresponding value from
Output Requirements
- After processing sales, print:
Stock after sales for <product_name>: <stock_level> units - After processing shipments, print:
Stock after shipment for <product_name>: <stock_level> units - At the end, print:
Final stock levels for all products: <products>
Requirements checklist
- After processing sales, for each product, check that the printed stock level matches the initial stock minus the corresponding units sold.
- After processing shipments, for each product, check that the printed stock level matches the stock after sales plus the corresponding shipment received.
- At the end, check that the printed final stock levels for all products match the initial stock minus units sold plus shipment received for each product.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 5. 章 5
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください