Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Sales and Shipments | Loops
Introduction to Python (copy)
course content

Kurssisisältö

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: 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.

Tehtävä

Swipe to start coding

Update product stock levels based on sales and shipments using loops.

  • Use a for loop with index iteration to go through the products list.
    • For each product subtract the number of units sold (units_sold) from the products stock.
  • Use a second for loop (also with index iteration) to go through products again.
    • Add the corresponding value from shipment_received to update the stock.

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>

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 5. Luku 5
toggle bottom row

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

Tehtävä

Swipe to start coding

Update product stock levels based on sales and shipments using loops.

  • Use a for loop with index iteration to go through the products list.
    • For each product subtract the number of units sold (units_sold) from the products stock.
  • Use a second for loop (also with index iteration) to go through products again.
    • Add the corresponding value from shipment_received to update the stock.

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>

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 5. Luku 5
Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Pahoittelemme, että jotain meni pieleen. Mitä tapahtui?
some-alt