From 04237b3da55c662e4943b46b3598a7c01a9273f9 Mon Sep 17 00:00:00 2001 From: Valeria Acevedo Date: Thu, 15 Jan 2026 21:05:50 +0100 Subject: [PATCH 1/2] Week1Lab1 done --- lab-python-data-structures.ipynb | 44 ++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..263b806f 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,51 @@ "\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": null, + "metadata": {}, + "outputs": [ + { + "ename": "", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[1;31mRunning cells with 'base (Python 3.13.11)' requires the ipykernel package.\n", + "\u001b[1;31mCreate a Python Environment with the required packages.\n", + "\u001b[1;31mOr install 'ipykernel' using the command: 'conda install -n base ipykernel --update-deps --force-reinstall'" + ] + } + ], + "source": [ + "products = [ \"t-shirt, mug, hat, book, keychain\" ]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "inventory = {}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for product in products:\n", + "quantity = int(input(f\"Enter quantity for {product}: \"))\n", + "inventory[product] = quantity" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -68,7 +108,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.11" } }, "nbformat": 4, From a26eba077ac4c364f69875ec0f1b3da7987fcb24 Mon Sep 17 00:00:00 2001 From: Valeria Acevedo Date: Sat, 17 Jan 2026 12:16:01 +0100 Subject: [PATCH 2/2] Week1 Lab1 Done --- lab-python-data-structures.ipynb | 204 ++++++++++++++++++++++++++++--- 1 file changed, 190 insertions(+), 14 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 263b806f..4ed4b573 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -55,20 +55,27 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1;31mRunning cells with 'base (Python 3.13.11)' requires the ipykernel package.\n", - "\u001b[1;31mCreate a Python Environment with the required packages.\n", - "\u001b[1;31mOr install 'ipykernel' using the command: 'conda install -n base ipykernel --update-deps --force-reinstall'" - ] - } - ], + "outputs": [], + "source": [ + "Exercise 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "products = [ \"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\" ]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ - "products = [ \"t-shirt, mug, hat, book, keychain\" ]" + "Exercise 2" ] }, { @@ -77,7 +84,34 @@ "metadata": {}, "outputs": [], "source": [ - "inventory = {}" + "inventory = { }" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "type=(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "inventory = {\"t-shirt\": 10, \"mug\": 2, \"hat\": 12, \"book\": 4, \"keychain\": 15}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Exercise 3" ] }, { @@ -90,6 +124,148 @@ "quantity = int(input(f\"Enter quantity for {product}: \"))\n", "inventory[product] = quantity" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Exercise 4" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "customers_orders = set ()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Exercise 5" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "customer_orders = set ()\n", + "\n", + "for _ in range(3):\n", + "product = input(\"Enter a product to order: \").lower()\n", + "if product in products:\n", + "customer_orders.add(product)\n", + "else:\n", + "print(\"Product not available.\")\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Exercise 6" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (\"Customer Orders\")\n", + "print(customer_orders)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Exercise 7" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "total_products_ordered = len(customer_orders)\n", + "percentage_ordered = (total_products_ordered / len(products)) * 100\n", + "\n", + "order_status = (total_products_ordered, percentage_ordered)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Exercise 8" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(\"Oder Statistics\")\n", + "print(\"Total Products Ordered: {order_status[0]}\")\n", + "print(f\"Percentage of Products Ordered: {order_status[1]}%\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Exercise 9" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for products in customer_orders:\n", + " if inventory (product) > 0:\n", + "inventory (product) -=1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Exercise 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(\"Updated Inventory:\")\n", + "for product, quantity in inventory.items():\n", + " print(f\"{product}: {quantity}\")\n" + ] } ], "metadata": {