Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.REPL.enableREPLSmartSend": false
}
103 changes: 101 additions & 2 deletions lab-python-flow-control.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,110 @@
"\n",
"3. Instead of updating the inventory by subtracting 1 from the quantity of each product, only do it for the products that were ordered (those in \"customer_orders\")."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "5b52af72",
"metadata": {},
"outputs": [],
"source": [
"products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "7d93b074",
"metadata": {},
"outputs": [],
"source": [
"inventory = {}"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "b3aa0754",
"metadata": {},
"outputs": [],
"source": [
"for i in products:\n",
" inventory[i] = int(input(f\"Cuantas unidades necesita de {i}? \"))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "1ffaf70b",
"metadata": {},
"outputs": [],
"source": [
"customer_orders = set()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "ce02d88b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Gracias por su compra\n"
]
}
],
"source": [
"continuar = \"yes\"\n",
"while continuar == \"yes\":\n",
" continuar = input(\"¿Quieres comprar un articulo? (yes/no): \").lower()\n",
" if continuar == \"yes\":\n",
" product = input(\"Ingrese el articulo: \")\n",
" if product in inventory:\n",
" customer_orders.add(product)\n",
" else:\n",
" print(\"Ese artículo no está en el inventario.\")\n",
" else:\n",
" print(\"Gracias por su compra\")"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "9d9541ca",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'mug', 'hat', 'book'}\n",
"{'t-shirt': 10, 'mug': 9, 'hat': 9, 'book': 9, 'keychain': 10}\n"
]
}
],
"source": [
"for product in customer_orders:\n",
" inventory[product] -= 1\n",
"print(customer_orders)\n",
"print(inventory)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e5c6f70b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -55,7 +154,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.14.7"
}
},
"nbformat": 4,
Expand Down