From f9e6c5d4dc5d5bb7de94a3d6a3e6cdf4c0472553 Mon Sep 17 00:00:00 2001 From: estefania <129790732+estefaniabarrosa@users.noreply.github.com> Date: Sat, 7 Mar 2026 11:30:51 +0000 Subject: [PATCH 1/2] Add files via upload --- lab-python-data-structures.ipynb | 152 +++++++++++++++---------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..6028852e 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -1,76 +1,76 @@ -{ - "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 -} +{ + "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 3140440ecd91db3ac12e3a1cafc5abee516aafc0 Mon Sep 17 00:00:00 2001 From: estefaniabarrosa Date: Sat, 7 Mar 2026 11:57:39 +0000 Subject: [PATCH 2/2] done lab --- lab-python-data-structures.ipynb | 47 +++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..3229e5b5 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,6 +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": [], + "source": [ + "products=[\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory={}\n", + "for product in products:\n", + " quantity = input(f\"Enter the quantity for {product}: \")\n", + " inventory[product] = int(quantity)\n", + "\n", + "customer_orders=set() \n", + "\n", + "while len(customer_orders)<3:\n", + " product=input(\"enter the name of a product you'd like to order: \").strip()\n", + " if product in products:\n", + " customer_orders.add(product)\n", + " else:\n", + " print(\"That's not a valid product. Please choose from the list.\")\n", + " print(\"Available products:\", \", \".join(products))\n", + " \n", + "print(\"customer order: \", customer_orders) \n", + "\n", + "total_products_ordered=len(customer_orders)\n", + "percentage_products_ordered=(total_products_ordered/len(products))*100\n", + "ordered_status=(total_products_ordered, percentage_products_ordered) \n", + "print(\"\"\"Order Statistics:\n", + " Total Products Ordered: \n", + " Percentage of Products Ordered: % \n", + " \"\"\")\n", + "\n", + "for product in customer_orders:\n", + " if product in inventory:\n", + " inventory[product]=max(0, inventory[product]-1)\n", + "print(\"Update inventory: \", inventory) \n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -68,7 +113,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.9" } }, "nbformat": 4,