Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Capstone Challenge | Other Data Types
Introduction to Python Video Course
course content

Conteúdo do Curso

Introduction to Python Video Course

Introduction to Python Video Course

1. Getting Started
2. Variables and Types
3. Conditional Statements
4. Other Data Types
5. Loops
6. Functions

Capstone Challenge

You are managing a grocery store's system, and you need to maintain decision-making for the inventory, track prices, and perform checks to determine if actions like restocking or removing items from the inventory are needed based on their price or stock.

Tarefa

  1. Complete the dictionary grocery_inventory by filling in the missing details. Each item should have a name as the key, and its value should be a tuple containing its category, a price, and its available stock quantity.
    ItemCategoryPriceStock
    MilkDairy3.508
    EggsDairy5.5030
    BreadBakery2.9915
    ApplesProduce1.5050
  2. Check the price of "Eggs". If the price is greater than $5, print a message that "Eggs" are too expensive and reduce the price by $1. If the price is $5 or less, print a message saying that the price of "Eggs" is reasonable.
  3. Add a new item "Tomatoes" to the grocery_inventory. The item should have a price of $1.20, belong to the "Produce" category, and have an initial stock of 30 units.
  4. Check if the stock of "Milk" is less than 10. If it is, print a message indicating that "Milk" needs to be restocked and increase the stock by 20 units. Otherwise, print that "Milk" has sufficient stock.
  5. Use a conditional statement to remove "Apples" from the inventory if their price exceeds $2.

Note

Keep in mind that once you've extracted a tuple from a dictionary, you can use square brackets to access its values by index. For instance, inventory["Bread"] retrieves the tuple associated with "Bread" from the dictionary, and inventory["Bread"][1] retrieves the price of "Bread", which is located at index 1 within the tuple.

Tarefa

  1. Complete the dictionary grocery_inventory by filling in the missing details. Each item should have a name as the key, and its value should be a tuple containing its category, a price, and its available stock quantity.
    ItemCategoryPriceStock
    MilkDairy3.508
    EggsDairy5.5030
    BreadBakery2.9915
    ApplesProduce1.5050
  2. Check the price of "Eggs". If the price is greater than $5, print a message that "Eggs" are too expensive and reduce the price by $1. If the price is $5 or less, print a message saying that the price of "Eggs" is reasonable.
  3. Add a new item "Tomatoes" to the grocery_inventory. The item should have a price of $1.20, belong to the "Produce" category, and have an initial stock of 30 units.
  4. Check if the stock of "Milk" is less than 10. If it is, print a message indicating that "Milk" needs to be restocked and increase the stock by 20 units. Otherwise, print that "Milk" has sufficient stock.
  5. Use a conditional statement to remove "Apples" from the inventory if their price exceeds $2.

Note

Keep in mind that once you've extracted a tuple from a dictionary, you can use square brackets to access its values by index. For instance, inventory["Bread"] retrieves the tuple associated with "Bread" from the dictionary, and inventory["Bread"][1] retrieves the price of "Bread", which is located at index 1 within the tuple.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 4. Capítulo 8
toggle bottom row

Capstone Challenge

You are managing a grocery store's system, and you need to maintain decision-making for the inventory, track prices, and perform checks to determine if actions like restocking or removing items from the inventory are needed based on their price or stock.

Tarefa

  1. Complete the dictionary grocery_inventory by filling in the missing details. Each item should have a name as the key, and its value should be a tuple containing its category, a price, and its available stock quantity.
    ItemCategoryPriceStock
    MilkDairy3.508
    EggsDairy5.5030
    BreadBakery2.9915
    ApplesProduce1.5050
  2. Check the price of "Eggs". If the price is greater than $5, print a message that "Eggs" are too expensive and reduce the price by $1. If the price is $5 or less, print a message saying that the price of "Eggs" is reasonable.
  3. Add a new item "Tomatoes" to the grocery_inventory. The item should have a price of $1.20, belong to the "Produce" category, and have an initial stock of 30 units.
  4. Check if the stock of "Milk" is less than 10. If it is, print a message indicating that "Milk" needs to be restocked and increase the stock by 20 units. Otherwise, print that "Milk" has sufficient stock.
  5. Use a conditional statement to remove "Apples" from the inventory if their price exceeds $2.

Note

Keep in mind that once you've extracted a tuple from a dictionary, you can use square brackets to access its values by index. For instance, inventory["Bread"] retrieves the tuple associated with "Bread" from the dictionary, and inventory["Bread"][1] retrieves the price of "Bread", which is located at index 1 within the tuple.

Tarefa

  1. Complete the dictionary grocery_inventory by filling in the missing details. Each item should have a name as the key, and its value should be a tuple containing its category, a price, and its available stock quantity.
    ItemCategoryPriceStock
    MilkDairy3.508
    EggsDairy5.5030
    BreadBakery2.9915
    ApplesProduce1.5050
  2. Check the price of "Eggs". If the price is greater than $5, print a message that "Eggs" are too expensive and reduce the price by $1. If the price is $5 or less, print a message saying that the price of "Eggs" is reasonable.
  3. Add a new item "Tomatoes" to the grocery_inventory. The item should have a price of $1.20, belong to the "Produce" category, and have an initial stock of 30 units.
  4. Check if the stock of "Milk" is less than 10. If it is, print a message indicating that "Milk" needs to be restocked and increase the stock by 20 units. Otherwise, print that "Milk" has sufficient stock.
  5. Use a conditional statement to remove "Apples" from the inventory if their price exceeds $2.

Note

Keep in mind that once you've extracted a tuple from a dictionary, you can use square brackets to access its values by index. For instance, inventory["Bread"] retrieves the tuple associated with "Bread" from the dictionary, and inventory["Bread"][1] retrieves the price of "Bread", which is located at index 1 within the tuple.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 4. Capítulo 8
toggle bottom row

Capstone Challenge

You are managing a grocery store's system, and you need to maintain decision-making for the inventory, track prices, and perform checks to determine if actions like restocking or removing items from the inventory are needed based on their price or stock.

Tarefa

  1. Complete the dictionary grocery_inventory by filling in the missing details. Each item should have a name as the key, and its value should be a tuple containing its category, a price, and its available stock quantity.
    ItemCategoryPriceStock
    MilkDairy3.508
    EggsDairy5.5030
    BreadBakery2.9915
    ApplesProduce1.5050
  2. Check the price of "Eggs". If the price is greater than $5, print a message that "Eggs" are too expensive and reduce the price by $1. If the price is $5 or less, print a message saying that the price of "Eggs" is reasonable.
  3. Add a new item "Tomatoes" to the grocery_inventory. The item should have a price of $1.20, belong to the "Produce" category, and have an initial stock of 30 units.
  4. Check if the stock of "Milk" is less than 10. If it is, print a message indicating that "Milk" needs to be restocked and increase the stock by 20 units. Otherwise, print that "Milk" has sufficient stock.
  5. Use a conditional statement to remove "Apples" from the inventory if their price exceeds $2.

Note

Keep in mind that once you've extracted a tuple from a dictionary, you can use square brackets to access its values by index. For instance, inventory["Bread"] retrieves the tuple associated with "Bread" from the dictionary, and inventory["Bread"][1] retrieves the price of "Bread", which is located at index 1 within the tuple.

Tarefa

  1. Complete the dictionary grocery_inventory by filling in the missing details. Each item should have a name as the key, and its value should be a tuple containing its category, a price, and its available stock quantity.
    ItemCategoryPriceStock
    MilkDairy3.508
    EggsDairy5.5030
    BreadBakery2.9915
    ApplesProduce1.5050
  2. Check the price of "Eggs". If the price is greater than $5, print a message that "Eggs" are too expensive and reduce the price by $1. If the price is $5 or less, print a message saying that the price of "Eggs" is reasonable.
  3. Add a new item "Tomatoes" to the grocery_inventory. The item should have a price of $1.20, belong to the "Produce" category, and have an initial stock of 30 units.
  4. Check if the stock of "Milk" is less than 10. If it is, print a message indicating that "Milk" needs to be restocked and increase the stock by 20 units. Otherwise, print that "Milk" has sufficient stock.
  5. Use a conditional statement to remove "Apples" from the inventory if their price exceeds $2.

Note

Keep in mind that once you've extracted a tuple from a dictionary, you can use square brackets to access its values by index. For instance, inventory["Bread"] retrieves the tuple associated with "Bread" from the dictionary, and inventory["Bread"][1] retrieves the price of "Bread", which is located at index 1 within the tuple.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

You are managing a grocery store's system, and you need to maintain decision-making for the inventory, track prices, and perform checks to determine if actions like restocking or removing items from the inventory are needed based on their price or stock.

Tarefa

  1. Complete the dictionary grocery_inventory by filling in the missing details. Each item should have a name as the key, and its value should be a tuple containing its category, a price, and its available stock quantity.
    ItemCategoryPriceStock
    MilkDairy3.508
    EggsDairy5.5030
    BreadBakery2.9915
    ApplesProduce1.5050
  2. Check the price of "Eggs". If the price is greater than $5, print a message that "Eggs" are too expensive and reduce the price by $1. If the price is $5 or less, print a message saying that the price of "Eggs" is reasonable.
  3. Add a new item "Tomatoes" to the grocery_inventory. The item should have a price of $1.20, belong to the "Produce" category, and have an initial stock of 30 units.
  4. Check if the stock of "Milk" is less than 10. If it is, print a message indicating that "Milk" needs to be restocked and increase the stock by 20 units. Otherwise, print that "Milk" has sufficient stock.
  5. Use a conditional statement to remove "Apples" from the inventory if their price exceeds $2.

Note

Keep in mind that once you've extracted a tuple from a dictionary, you can use square brackets to access its values by index. For instance, inventory["Bread"] retrieves the tuple associated with "Bread" from the dictionary, and inventory["Bread"][1] retrieves the price of "Bread", which is located at index 1 within the tuple.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 4. Capítulo 8
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt