From a66f8310fe1c050ec9e2f89fa4b8b89412747762 Mon Sep 17 00:00:00 2001 From: Olga Galanina Date: Thu, 15 Jan 2026 21:12:41 +0100 Subject: [PATCH 1/2] Week1Lab1 Done --- lab-python-data-structures.ipynb | 72 +++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..9e46a641 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,79 @@ "\n", "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations. " ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "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." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Customer Orders:\n", + "\n", + "Inventory:\n", + "{'t-shirt': 34, 'mug': 56, 'hat': 87, 'book': 56, 'keychain': 45}\n" + ] + } + ], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "quantity1 = int(input(\"Enter the quantity of a product:\"))\n", + "inventory[\"t-shirt\"] = quantity1\n", + "\n", + "quantity2 = int(input(\"Enter the quantity of a product:\"))\n", + "inventory[\"mug\"] = quantity2\n", + "\n", + "quantity3 = int(input(\"Enter the quantity of a product:\"))\n", + "inventory[\"hat\"] = quantity3\n", + "\n", + "quantity4 = int(input(\"Enter the quantity of a product:\"))\n", + "inventory[\"book\"] = quantity4\n", + "\n", + "quantity5 = int(input(\"Enter the quantity of a product:\"))\n", + "inventory[\"keychain\"] = quantity5\n", + "\n", + "\n", + "customer_orders = set()\n", + "product1 = (input(\"Input the name of a product:\"))\n", + "customer_orders.add(product1)\n", + "\n", + "product2 = (input(\"Input the name of a product:\"))\n", + "customer_orders.add(product2)\n", + "\n", + "product3 = (input(\"Input the name of a product:\"))\n", + "customer_orders.add(product3)\n", + "\n", + "print(\"\\nCustomer Orders:\")\n", + "\n", + "print(\"\\nInventory:\")\n", + "print(inventory)\n" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -68,7 +136,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.9" } }, "nbformat": 4, From b85031b541d5cb293abafc9ced2a4c7229d74f56 Mon Sep 17 00:00:00 2001 From: Olga Galanina Date: Fri, 16 Jan 2026 23:00:09 +0100 Subject: [PATCH 2/2] Week1Lab1 Done --- lab-python-data-structures.ipynb | 84 ++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 9e46a641..e48e363e 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -51,72 +51,82 @@ "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations. " ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "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." - ] - }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "\n", - "Customer Orders:\n", - "\n", + "Customer Orders: {'23', '67', '87'}\n", "Inventory:\n", - "{'t-shirt': 34, 'mug': 56, 'hat': 87, 'book': 56, 'keychain': 45}\n" + "{'t-shirt': 12, 'mug': 23, 'hat': 45, 'book': 56, 'keychain': 65}\n" ] } ], "source": [ "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "\n", "inventory = {}\n", - "quantity1 = int(input(\"Enter the quantity of a product:\"))\n", + "\n", + "#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", + "quantity1 = int(input(\"Enter the quantity for t-shirt: \"))\n", "inventory[\"t-shirt\"] = quantity1\n", "\n", - "quantity2 = int(input(\"Enter the quantity of a product:\"))\n", + "quantity2 = int(input(\"Enter the quantity for mug: \"))\n", "inventory[\"mug\"] = quantity2\n", "\n", - "quantity3 = int(input(\"Enter the quantity of a product:\"))\n", - "inventory[\"hat\"] = quantity3\n", + "quantity3 = int(input(\"Enter the quantity for hat: \"))\n", + "inventory[\"hat\"] = quantity3 \n", "\n", - "quantity4 = int(input(\"Enter the quantity of a product:\"))\n", + "quantity4 = int(input(\"Enter the quantity for book: \"))\n", "inventory[\"book\"] = quantity4\n", "\n", - "quantity5 = int(input(\"Enter the quantity of a product:\"))\n", + "quantity5 = int(input(\"Enter the quantity for keychain: \"))\n", "inventory[\"keychain\"] = quantity5\n", "\n", + "inventory\n", + "\n", + "customer_order = set()\n", + "\n", + "product1 = input(\"Enter the product you want to order: \")\n", + "customer_order.add(product1)\n", + "\n", + "product2 = input(\"Enter the product you want to order: \")\n", + "customer_order.add(product2)\n", + "\n", + "product3 = input(\"Enter the product you want to order: \")\n", + "customer_order.add(product3)\n", + "\n", + "print(\"Customer order:\", customer_order)\n", + "\n", + "total_products_ordered = len(customer_order)\n", + "percentage_of_products_ordered = total_products_ordered/ len(products) * 100\n", + "\n", + "order_status = tuple()\n", + "order_status = (total_products_ordered, percentage_of_products_ordered)\n", + "\n", + "print(\"Total Products Ordered:\", total_products_ordered)\n", + "\n", + "print(f\"Percentage of Products Ordered: {percentage_of_products_ordered}%\")\n", + "\n", "\n", - "customer_orders = set()\n", - "product1 = (input(\"Input the name of a product:\"))\n", - "customer_orders.add(product1)\n", + "#Update the inventory by subtracting 1 from the quantity of each product. Modify the `inventory` dictionary accordingly.\n", "\n", - "product2 = (input(\"Input the name of a product:\"))\n", - "customer_orders.add(product2)\n", + "inventory[product1] = inventory[product1] - 1\n", + "inventory[product2] = inventory[product2] - 1\n", + "inventory[product3] = inventory[product3] - 1\n", "\n", - "product3 = (input(\"Input the name of a product:\"))\n", - "customer_orders.add(product3)\n", "\n", - "print(\"\\nCustomer Orders:\")\n", + "#Print the updated inventory, displaying the quantity of each product on separate lines.\n", "\n", - "print(\"\\nInventory:\")\n", - "print(inventory)\n" + "print(\"Updated quantity for t-shirt:\", inventory[\"t-shirt\"])\n", + "print(\"Updated quantity for mug:\", inventory[\"mug\"])\n", + "print(\"Updated quantity for hat:\", inventory[\"hat\"])\n", + "print(\"Updated quantity for book:\", inventory[\"book\"])\n", + "print(\"Updated quantity for keychain:\", inventory[\"keychain\"])\n" ] } ],