From a32b4148edaad050c970b6216707a41839b7fc92 Mon Sep 17 00:00:00 2001 From: Mandana Soltani Date: Sat, 7 Mar 2026 20:57:22 +0100 Subject: [PATCH 1/5] Add files via upload --- Python_Data_Structures.ipynb | 332 +++++++++++++++++++++++++++++++++++ 1 file changed, 332 insertions(+) create mode 100644 Python_Data_Structures.ipynb diff --git a/Python_Data_Structures.ipynb b/Python_Data_Structures.ipynb new file mode 100644 index 00000000..451e832c --- /dev/null +++ b/Python_Data_Structures.ipynb @@ -0,0 +1,332 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "As part of a business venture, you are starting an online store that sells various products. To ensure smooth operations, you need to develop a program that manages customer orders and inventory.\n", + "Follow the steps below to complete the exercise:\n", + "1. Define a list called `products` that contains the following items: \"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\".\n", + "2. Create an empty dictionary called `inventory`.\n", + "3. Ask the user to input the quantity of each product available in the inventory. Use the product names from the `products` list as keys in the `inventory` dictionary and assign the respective quantities as values.\n", + "4. Create an empty set called `customer_orders`.\n", + "5. Ask the user to input the name of three products that a customer wants to order (from those in the products list, meaning three products out of \"t-shirt\", \"mug\", \"hat\", \"book\" or \"keychain\". Add each product name to the `customer_orders` set.\n", + "6. Print the products in the `customer_orders` set.\n", + "7. Calculate the following order statistics:\n", + " - Total Products Ordered: The total number of products in the `customer_orders` set.\n", + " - Percentage of Products Ordered: The percentage of products ordered compared to the total available products.\n", + " Store these statistics in a tuple called `order_status`.\n", + "8. Print the order statistics using the following format:\n", + " ```\n", + " Order Statistics:\n", + " Total Products Ordered: \n", + " Percentage of Products Ordered: %\n", + " ```\n", + "9. Update the inventory by subtracting 1 from the quantity of each product. Modify the `inventory` dictionary accordingly.\n", + "10. Print the updated inventory, displaying the quantity of each product on separate lines.\n", + "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations.\n" + ], + "metadata": { + "id": "qmmofN7CjbGq" + } + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "ss76EuNWemc9", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "a8cde897-a5f7-4ac3-d4f2-d87d7f2e86e3" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter quantity for t-shirt: 10\n", + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", + "Enter quantity for mug: 12\n", + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", + "Enter quantity for hat: 8\n", + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", + "Enter quantity for book: 5\n", + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", + "Enter quantity for keychain: 6\n", + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n" + ] + } + ], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "for product in products:\n", + " quantity = int(input(f\"Enter quantity for {product}: \"))\n", + " inventory[product] = quantity\n", + " print(products)\n", + " customers_orders = set()\n", + "for i in products.max(3):\n", + " order = input(\"Enter a product to order: \")\n", + " customer_orders.add(order)\n", + " print(Customers_orders)\n", + "Total_products_ordered = len(customer_orders)\n", + "print(Total_products_ordered)\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "source": [ + "\n", + "\n" + ], + "metadata": { + "id": "lNShmhuauoat" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "\n" + ], + "metadata": { + "id": "fNXi4BNOtWt3" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "print(products)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "eRnqROpejjXs", + "outputId": "835ad3a3-ca26-41ad-d3f5-bbc2f3bce315" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "print(inventory)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "ICDV1vqHj_yp", + "outputId": "968847d6-7626-44c0-c6e0-77fa6ce1c1a1" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "{'t-shirt': 10, 'mug': 12, 'hat': 8, 'book': 5, 'keychain': 6}\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "\n", + "\n" + ], + "metadata": { + "id": "c3WYovsbkDSw", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 207 + }, + "outputId": "db3d7e31-1782-4e27-b919-a8df03698a22" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "error", + "ename": "AttributeError", + "evalue": "'list' object has no attribute 'max'", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/tmp/ipykernel_671/991310304.py\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mCustomers_orders\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mproducts\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmax\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0morders\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Enter a product to order: \"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mcustomer_orders\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0morder\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mCustomers_orders\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mAttributeError\u001b[0m: 'list' object has no attribute 'max'" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "customer_orders = set()\n", + "\n", + "for i in range(3):\n", + " order = input(\"Enter a product to order: \")\n", + " customer_orders.add(order)" + ], + "metadata": { + "id": "ZhLQASj0qKCI", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "a4ddfaa0-53c1-441b-aa2e-49166e14772f" + }, + "execution_count": null, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Enter a product to order: mug\n", + "Enter a product to order: hat\n", + "Enter a product to order: book\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [], + "metadata": { + "id": "ZBSl0Fnysr9r" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "total_products_ordered = len(customer_orders)\n", + "\n", + "percentage_ordered = (total_products_ordered / len(products)) * 100\n", + "\n", + "order_status = (total_products_ordered, percentage_ordered)" + ], + "metadata": { + "id": "FeYIaEsRxcWa" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "print(\"Order Statistics:\")\n", + "print(\"Total Products Ordered\", total_products_ordered)\n", + "print(\"Percentage Ordered\", percentage_ordered)\n", + "inventory = {product : inventory[product] - 1 for product in customer_orders}\n", + "print\n", + "\n", + "\n", + "\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "c0_rUanOxdiS", + "outputId": "3500c606-a33b-41ad-8b40-d6886173c223" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Order Statistics:\n", + "Total Products Ordered 3\n", + "Percentage Ordered 60.0\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "for product in customer_orders:\n", + " inventory[product] -= 1" + ], + "metadata": { + "id": "lrYbRWXh1dNd" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "for product, quantity in inventory.items():\n", + " print(product, quantity)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "EMW1qGBk1epb", + "outputId": "5502e43c-59b0-437f-d789-c8fc770f58be" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "t-shirt 10\n", + "mug 9\n", + "hat 5\n", + "book 2\n", + "keychain 6\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "def inventory(product, quantity):\n", + " updated_inventory = product + quantity\n", + " return updated_inventory" + ], + "metadata": { + "id": "aHKGHsFN3LcS" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file From 216d25a4c494d1373bdfd7bfbb3540f12d57ba8d Mon Sep 17 00:00:00 2001 From: Mandana Soltani Date: Sat, 7 Mar 2026 21:19:37 +0100 Subject: [PATCH 2/5] Add files via upload --- lab-python-data-structures.ipynb.ipynb | 332 +++++++++++++++++++++++++ 1 file changed, 332 insertions(+) create mode 100644 lab-python-data-structures.ipynb.ipynb diff --git a/lab-python-data-structures.ipynb.ipynb b/lab-python-data-structures.ipynb.ipynb new file mode 100644 index 00000000..451e832c --- /dev/null +++ b/lab-python-data-structures.ipynb.ipynb @@ -0,0 +1,332 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "As part of a business venture, you are starting an online store that sells various products. To ensure smooth operations, you need to develop a program that manages customer orders and inventory.\n", + "Follow the steps below to complete the exercise:\n", + "1. Define a list called `products` that contains the following items: \"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\".\n", + "2. Create an empty dictionary called `inventory`.\n", + "3. Ask the user to input the quantity of each product available in the inventory. Use the product names from the `products` list as keys in the `inventory` dictionary and assign the respective quantities as values.\n", + "4. Create an empty set called `customer_orders`.\n", + "5. Ask the user to input the name of three products that a customer wants to order (from those in the products list, meaning three products out of \"t-shirt\", \"mug\", \"hat\", \"book\" or \"keychain\". Add each product name to the `customer_orders` set.\n", + "6. Print the products in the `customer_orders` set.\n", + "7. Calculate the following order statistics:\n", + " - Total Products Ordered: The total number of products in the `customer_orders` set.\n", + " - Percentage of Products Ordered: The percentage of products ordered compared to the total available products.\n", + " Store these statistics in a tuple called `order_status`.\n", + "8. Print the order statistics using the following format:\n", + " ```\n", + " Order Statistics:\n", + " Total Products Ordered: \n", + " Percentage of Products Ordered: %\n", + " ```\n", + "9. Update the inventory by subtracting 1 from the quantity of each product. Modify the `inventory` dictionary accordingly.\n", + "10. Print the updated inventory, displaying the quantity of each product on separate lines.\n", + "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations.\n" + ], + "metadata": { + "id": "qmmofN7CjbGq" + } + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "ss76EuNWemc9", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "a8cde897-a5f7-4ac3-d4f2-d87d7f2e86e3" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter quantity for t-shirt: 10\n", + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", + "Enter quantity for mug: 12\n", + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", + "Enter quantity for hat: 8\n", + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", + "Enter quantity for book: 5\n", + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", + "Enter quantity for keychain: 6\n", + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n" + ] + } + ], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "for product in products:\n", + " quantity = int(input(f\"Enter quantity for {product}: \"))\n", + " inventory[product] = quantity\n", + " print(products)\n", + " customers_orders = set()\n", + "for i in products.max(3):\n", + " order = input(\"Enter a product to order: \")\n", + " customer_orders.add(order)\n", + " print(Customers_orders)\n", + "Total_products_ordered = len(customer_orders)\n", + "print(Total_products_ordered)\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "source": [ + "\n", + "\n" + ], + "metadata": { + "id": "lNShmhuauoat" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "\n" + ], + "metadata": { + "id": "fNXi4BNOtWt3" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "print(products)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "eRnqROpejjXs", + "outputId": "835ad3a3-ca26-41ad-d3f5-bbc2f3bce315" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "print(inventory)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "ICDV1vqHj_yp", + "outputId": "968847d6-7626-44c0-c6e0-77fa6ce1c1a1" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "{'t-shirt': 10, 'mug': 12, 'hat': 8, 'book': 5, 'keychain': 6}\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "\n", + "\n" + ], + "metadata": { + "id": "c3WYovsbkDSw", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 207 + }, + "outputId": "db3d7e31-1782-4e27-b919-a8df03698a22" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "error", + "ename": "AttributeError", + "evalue": "'list' object has no attribute 'max'", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/tmp/ipykernel_671/991310304.py\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mCustomers_orders\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mproducts\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmax\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0morders\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Enter a product to order: \"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mcustomer_orders\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0morder\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mCustomers_orders\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mAttributeError\u001b[0m: 'list' object has no attribute 'max'" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "customer_orders = set()\n", + "\n", + "for i in range(3):\n", + " order = input(\"Enter a product to order: \")\n", + " customer_orders.add(order)" + ], + "metadata": { + "id": "ZhLQASj0qKCI", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "a4ddfaa0-53c1-441b-aa2e-49166e14772f" + }, + "execution_count": null, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Enter a product to order: mug\n", + "Enter a product to order: hat\n", + "Enter a product to order: book\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [], + "metadata": { + "id": "ZBSl0Fnysr9r" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "total_products_ordered = len(customer_orders)\n", + "\n", + "percentage_ordered = (total_products_ordered / len(products)) * 100\n", + "\n", + "order_status = (total_products_ordered, percentage_ordered)" + ], + "metadata": { + "id": "FeYIaEsRxcWa" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "print(\"Order Statistics:\")\n", + "print(\"Total Products Ordered\", total_products_ordered)\n", + "print(\"Percentage Ordered\", percentage_ordered)\n", + "inventory = {product : inventory[product] - 1 for product in customer_orders}\n", + "print\n", + "\n", + "\n", + "\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "c0_rUanOxdiS", + "outputId": "3500c606-a33b-41ad-8b40-d6886173c223" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Order Statistics:\n", + "Total Products Ordered 3\n", + "Percentage Ordered 60.0\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "for product in customer_orders:\n", + " inventory[product] -= 1" + ], + "metadata": { + "id": "lrYbRWXh1dNd" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "for product, quantity in inventory.items():\n", + " print(product, quantity)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "EMW1qGBk1epb", + "outputId": "5502e43c-59b0-437f-d789-c8fc770f58be" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "t-shirt 10\n", + "mug 9\n", + "hat 5\n", + "book 2\n", + "keychain 6\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "def inventory(product, quantity):\n", + " updated_inventory = product + quantity\n", + " return updated_inventory" + ], + "metadata": { + "id": "aHKGHsFN3LcS" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file From 0854fa41e3907b61d1b3a6d068105a0b34aab3c1 Mon Sep 17 00:00:00 2001 From: Mandana Soltani Date: Sat, 7 Mar 2026 21:25:10 +0100 Subject: [PATCH 3/5] Delete lab-python-data-structures.ipynb --- lab-python-data-structures.ipynb | 76 -------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 lab-python-data-structures.ipynb diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb deleted file mode 100644 index 5b3ce9e0..00000000 --- a/lab-python-data-structures.ipynb +++ /dev/null @@ -1,76 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "tags": [] - }, - "source": [ - "# Lab | Data Structures " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exercise: Managing Customer Orders\n", - "\n", - "As part of a business venture, you are starting an online store that sells various products. To ensure smooth operations, you need to develop a program that manages customer orders and inventory.\n", - "\n", - "Follow the steps below to complete the exercise:\n", - "\n", - "1. Define a list called `products` that contains the following items: \"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\".\n", - "\n", - "2. Create an empty dictionary called `inventory`.\n", - "\n", - "3. Ask the user to input the quantity of each product available in the inventory. Use the product names from the `products` list as keys in the `inventory` dictionary and assign the respective quantities as values.\n", - "\n", - "4. Create an empty set called `customer_orders`.\n", - "\n", - "5. Ask the user to input the name of three products that a customer wants to order (from those in the products list, meaning three products out of \"t-shirt\", \"mug\", \"hat\", \"book\" or \"keychain\". Add each product name to the `customer_orders` set.\n", - "\n", - "6. Print the products in the `customer_orders` set.\n", - "\n", - "7. Calculate the following order statistics:\n", - " - Total Products Ordered: The total number of products in the `customer_orders` set.\n", - " - Percentage of Products Ordered: The percentage of products ordered compared to the total available products.\n", - " \n", - " Store these statistics in a tuple called `order_status`.\n", - "\n", - "8. Print the order statistics using the following format:\n", - " ```\n", - " Order Statistics:\n", - " Total Products Ordered: \n", - " Percentage of Products Ordered: % \n", - " ```\n", - "\n", - "9. Update the inventory by subtracting 1 from the quantity of each product. Modify the `inventory` dictionary accordingly.\n", - "\n", - "10. Print the updated inventory, displaying the quantity of each product on separate lines.\n", - "\n", - "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations. " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.13" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} From fb7ea20d114af4f793de0b782ae5651ea6f903ef Mon Sep 17 00:00:00 2001 From: Mandana Soltani Date: Sat, 7 Mar 2026 21:28:04 +0100 Subject: [PATCH 4/5] Add files via upload From c661c41288feedbb3b97f23ccb8aab8974224f82 Mon Sep 17 00:00:00 2001 From: Mandana Soltani Date: Sat, 7 Mar 2026 21:30:17 +0100 Subject: [PATCH 5/5] Rename lab-python-data-structures.ipynb.ipynb to lab-python-data-structures.ipynb --- ...a-structures.ipynb.ipynb => lab-python-data-structures.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename lab-python-data-structures.ipynb.ipynb => lab-python-data-structures.ipynb (99%) diff --git a/lab-python-data-structures.ipynb.ipynb b/lab-python-data-structures.ipynb similarity index 99% rename from lab-python-data-structures.ipynb.ipynb rename to lab-python-data-structures.ipynb index 451e832c..f7057ace 100644 --- a/lab-python-data-structures.ipynb.ipynb +++ b/lab-python-data-structures.ipynb @@ -329,4 +329,4 @@ "outputs": [] } ] -} \ No newline at end of file +}