Conteúdo do Curso
Introduction to Python Video Course
Introduction to Python Video Course
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
- 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.Item Category Price Stock Milk Dairy 3.50 8 Eggs Dairy 5.50 30 Bread Bakery 2.99 15 Apples Produce 1.50 50 - 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. - Add a new item
"Tomatoes"
to thegrocery_inventory
. The item should have a price of $1.20, belong to the"Produce"
category, and have an initial stock of30
units. - Check if the stock of
"Milk"
is less than10
. If it is, print a message indicating that"Milk"
needs to be restocked and increase the stock by20
units. Otherwise, print that"Milk"
has sufficient stock. - 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, andinventory["Bread"][1]
retrieves the price of"Bread"
, which is located at index1
within the tuple.
Tarefa
- 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.Item Category Price Stock Milk Dairy 3.50 8 Eggs Dairy 5.50 30 Bread Bakery 2.99 15 Apples Produce 1.50 50 - 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. - Add a new item
"Tomatoes"
to thegrocery_inventory
. The item should have a price of $1.20, belong to the"Produce"
category, and have an initial stock of30
units. - Check if the stock of
"Milk"
is less than10
. If it is, print a message indicating that"Milk"
needs to be restocked and increase the stock by20
units. Otherwise, print that"Milk"
has sufficient stock. - 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, andinventory["Bread"][1]
retrieves the price of"Bread"
, which is located at index1
within the tuple.
Tudo estava claro?
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
- 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.Item Category Price Stock Milk Dairy 3.50 8 Eggs Dairy 5.50 30 Bread Bakery 2.99 15 Apples Produce 1.50 50 - 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. - Add a new item
"Tomatoes"
to thegrocery_inventory
. The item should have a price of $1.20, belong to the"Produce"
category, and have an initial stock of30
units. - Check if the stock of
"Milk"
is less than10
. If it is, print a message indicating that"Milk"
needs to be restocked and increase the stock by20
units. Otherwise, print that"Milk"
has sufficient stock. - 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, andinventory["Bread"][1]
retrieves the price of"Bread"
, which is located at index1
within the tuple.
Tarefa
- 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.Item Category Price Stock Milk Dairy 3.50 8 Eggs Dairy 5.50 30 Bread Bakery 2.99 15 Apples Produce 1.50 50 - 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. - Add a new item
"Tomatoes"
to thegrocery_inventory
. The item should have a price of $1.20, belong to the"Produce"
category, and have an initial stock of30
units. - Check if the stock of
"Milk"
is less than10
. If it is, print a message indicating that"Milk"
needs to be restocked and increase the stock by20
units. Otherwise, print that"Milk"
has sufficient stock. - 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, andinventory["Bread"][1]
retrieves the price of"Bread"
, which is located at index1
within the tuple.
Tudo estava claro?
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
- 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.Item Category Price Stock Milk Dairy 3.50 8 Eggs Dairy 5.50 30 Bread Bakery 2.99 15 Apples Produce 1.50 50 - 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. - Add a new item
"Tomatoes"
to thegrocery_inventory
. The item should have a price of $1.20, belong to the"Produce"
category, and have an initial stock of30
units. - Check if the stock of
"Milk"
is less than10
. If it is, print a message indicating that"Milk"
needs to be restocked and increase the stock by20
units. Otherwise, print that"Milk"
has sufficient stock. - 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, andinventory["Bread"][1]
retrieves the price of"Bread"
, which is located at index1
within the tuple.
Tarefa
- 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.Item Category Price Stock Milk Dairy 3.50 8 Eggs Dairy 5.50 30 Bread Bakery 2.99 15 Apples Produce 1.50 50 - 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. - Add a new item
"Tomatoes"
to thegrocery_inventory
. The item should have a price of $1.20, belong to the"Produce"
category, and have an initial stock of30
units. - Check if the stock of
"Milk"
is less than10
. If it is, print a message indicating that"Milk"
needs to be restocked and increase the stock by20
units. Otherwise, print that"Milk"
has sufficient stock. - 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, andinventory["Bread"][1]
retrieves the price of"Bread"
, which is located at index1
within the tuple.
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
- 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.Item Category Price Stock Milk Dairy 3.50 8 Eggs Dairy 5.50 30 Bread Bakery 2.99 15 Apples Produce 1.50 50 - 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. - Add a new item
"Tomatoes"
to thegrocery_inventory
. The item should have a price of $1.20, belong to the"Produce"
category, and have an initial stock of30
units. - Check if the stock of
"Milk"
is less than10
. If it is, print a message indicating that"Milk"
needs to be restocked and increase the stock by20
units. Otherwise, print that"Milk"
has sufficient stock. - 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, andinventory["Bread"][1]
retrieves the price of"Bread"
, which is located at index1
within the tuple.