diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..7247098f 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -21,19 +21,81 @@ "\n", "1. Define a list called `products` that contains the following items: \"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\".\n", "\n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "\n", + "\n", "2. Create an empty dictionary called `inventory`.\n", "\n", + "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", + "\n", + "quantity_tshirts = int(input (\"T-shirts quant: \"))\n", + "inventory [\"t-shirt\"] = quantity_tshirts\n", + "\n", + "quantity_mug = int (input (\"mug quant: \"))\n", + "inventory [\"mug] = quantity_mug\n", + "\n", + "quantity_hat = int (input (\"hat quant: \"))\n", + "inventory [\"hat] = quantity_hat\n", + "\n", + "quantity_book = int (input (\"book quant: \"))\n", + "inventory [\"book\"] = quantity_book\n", + "\n", + "quantity_keychain = int (input (\"keychain quant: \"))\n", + "inventory [\"keychain\"] = quantity_keychain\n", + "\n", + "\n", "4. Create an empty set called `customer_orders`.\n", "\n", + "\n", + "customer_orders = set ()\n", + "\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", + "\n", + "product1 = input (\"product_name\")\n", + "customer_orders.add(product1)\n", + "\n", + "product2 = input (\"product_name)\n", + "customer_orders.add(product2)\n", + "\n", + "product3= unput (\"product_name)\n", + "customer_orders.add(product3)\n", + "\n", + "\n", "6. Print the products in the `customer_orders` set.\n", "\n", + "\n", + "customer_orders = set ()\n", + "product1 = input (\"product_name\")\n", + "customer_orders.add(product1)\n", + "\n", + "product2 = input (\"product_name\")\n", + "customer_orders.add(product2)\n", + "\n", + "product3= input (\"product_name\")\n", + "customer_orders.add(product3)\n", + "\n", + "print (customer_orders)\n", + "\n", + "\n", "7. Calculate the following order statistics:\n", + "\n", " - Total Products Ordered: The total number of products in the `customer_orders` set.\n", + "\n", + "from customer_orders:\n", + "total_pedidos = len(customer_orders)\n", + "print(\"NĂºmero total de productos pedidos:\", total_pedidos)\n", + "\n", + "\n", " - Percentage of Products Ordered: The percentage of products ordered compared to the total available products.\n", + "\n", + "total_pedidos = len(customer_orders)\n", + "total_disponibles = len(inventory)\n", + "porcentaje_pedidos = (total_pedidos / total_disponibles) * 100\n", " \n", " Store these statistics in a tuple called `order_status`.\n", "\n",