diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..c75c865d 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -1,14 +1,5 @@ { "cells": [ - { - "cell_type": "markdown", - "metadata": { - "tags": [] - }, - "source": [ - "# Lab | Data Structures " - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -50,11 +41,70 @@ "\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": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'hat'}\n", + "Order Statistics:\n", + "Total Products Ordered: 1\n", + "Percentage of Products Ordered: 20.0%\n", + "{'hat', 'mug'}\n", + "Order Statistics:\n", + "Total Products Ordered: 2\n", + "Percentage of Products Ordered: 40.0%\n", + "{'book', 'hat', 'mug'}\n", + "Order Statistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60.0%\n", + "t-shirt: 38\n", + "mug: 59\n", + "hat: 24\n", + "book: 869\n", + "keychain: 20\n" + ] + } + ], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "for product in products:\n", + " quantity = int(input(f\"Enter the quantity of {product}: \"))\n", + " inventory[product] = quantity\n", + "\n", + "customer_orders = set()\n", + "for i in range(3):\n", + " order = input(f\"Enter the name of product {i+1} to order: \")\n", + " customer_orders.add(order)\n", + " print(customer_orders)\n", + "\n", + " total_products_ordered = len(customer_orders)\n", + " percentage_ordered = (total_products_ordered / len(products)) * 100\n", + " order_status = (total_products_ordered, percentage_ordered)\n", + " print(\"Order Statistics:\") \n", + " print(f\"Total Products Ordered: {order_status[0]}\")\n", + " print(f\"Percentage of Products Ordered: {order_status[1]}%\")\n", + "\n", + "for product in customer_orders:\n", + " if product in inventory:\n", + " inventory[product] -= 1\n", + "\n", + "for product, quantity in inventory.items():\n", + " print(f\"{product}: {quantity}\") \n", + " \n", + " " + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "data-analyst", "language": "python", "name": "python3" }, @@ -68,7 +118,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.5" } }, "nbformat": 4,