From 6dc92f39b421fc49249ad0916051304637328c91 Mon Sep 17 00:00:00 2001 From: sergiocruz9 Date: Mon, 13 Oct 2025 17:41:14 +0200 Subject: [PATCH] W01L01 Done --- lab-python-data-structures.ipynb | 159 ++++++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..14588f28 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,166 @@ "\n", "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations. " ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "productsBV = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"] " + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 30, 'mug': 20, 'hat': 23, 'book': 23, 'keychain': 24}\n" + ] + } + ], + "source": [ + "inventoryBV={}\n", + "for pkeys in productsBV:\n", + " inventoryBV[f\"{pkeys}\"]=int(input(f\"enter quantity of product available for {pkeys} in the inventory\"))\n", + " \n", + "print(inventoryBV)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "customer order= {'mug', 'book', 'hat'}\n" + ] + } + ], + "source": [ + "custom_orders=set()\n", + "\n", + "while len(custom_orders)<3:\n", + " custom_orders.add(input(\"enter the name of the product you want to order, between t-shirts, mug, hat, book, keychain\"))\n", + "print(f\"customer order= {custom_orders}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "total_items_ordered=len(custom_orders)\n", + "percentageproductorder=total_items_ordered/sum(inventoryBV.values())*100\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Order statistics:\n", + "Total Products Ordered=3\n", + "Percentage of Products Ordered: 2.50\n" + ] + } + ], + "source": [ + "print(f\"\"\"Order statistics:\n", + "Total Products Ordered={total_items_ordered}\n", + "Percentage of Products Ordered: {percentageproductorder:.2f}\"\"\")" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "product=t-shirt, quantity in inventory=30\n", + "product=mug, quantity in inventory=19\n", + "product=hat, quantity in inventory=22\n", + "product=book, quantity in inventory=22\n", + "product=keychain, quantity in inventory=24\n" + ] + } + ], + "source": [ + "\n", + "for orders in custom_orders:\n", + " if orders in inventoryBV:\n", + " inventoryBV[orders]-=1\n", + "\n", + "for keys, values in inventoryBV.items():\n", + " print(f\"product={keys}, quantity in inventory={values}\")\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 30, 'mug': 19, 'hat': 22, 'book': 22, 'keychain': 24}\n" + ] + } + ], + "source": [ + "print(inventoryBV)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "#THIS END OF LAB 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -68,7 +223,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.5" } }, "nbformat": 4,