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
74 changes: 74 additions & 0 deletions flow-control-python.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n",
"\n",
"inventory = {}\n",
"\n",
"for product in products:\n",
" print (\"Enter the quantity of each product available in the inventory for \" + product + \" : \")\n",
" quantity = int(input())\n",
" inventory[product] = quantity\n",
"\n",
"customer_orders = set()\n",
"\n",
"while True:\n",
" order = input(\"Enter product ordered: \").lower()\n",
" \n",
" if order in products: # On vérifie que le produit existe\n",
" customer_orders.add(order)\n",
" else:\n",
" print(\"This product is not available in the store.\")\n",
"\n",
" more = input(\"Do you want to add another product? (yes/no): \").lower()\n",
" if more != \"yes\":\n",
" break\n",
"\n",
"print(\"Products ordered:\", customer_orders)\n",
"\n",
"total_products_ordered = len(customer_orders)\n",
"percentage_ordered = (total_products_ordered / len(products)) * 100\n",
"order_status = (total_products_ordered, percentage_ordered)\n",
"\n",
"print(\"\\nOrder Statistics:\")\n",
"print(\"Total Products Ordered:\", order_status[0])\n",
"print(\"Percentage of Products Ordered:\", round(order_status[1], 2), \"%\")\n",
"\n",
"for item in customer_orders:\n",
" if item in inventory:\n",
" inventory[item] -= 1\n",
"\n",
"print(\"\\nUpdated Inventory:\")\n",
"for product, quantity in inventory.items():\n",
" print(product, \":\", quantity)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": []
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
63 changes: 0 additions & 63 deletions lab-python-flow-control.ipynb

This file was deleted.