diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e..b4e09a3 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -10,8 +10,200 @@ ] }, { - "cell_type": "markdown", + "cell_type": "code", + "execution_count": 2, "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Enter quantity t-shirt: 10\n", + "Enter quality mug: 10\n", + "Enter quality hat: 10\n", + "Enter quality book: 10\n", + "Enter quality keychain: 10\n" + ] + } + ], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "quantity_tshirt = int(input(\"Enter quantity t-shirt: \"))\n", + "quantity_mug = int(input(\"Enter quality mug: \"))\n", + "quantity_hat = int(input(\"Enter quality hat: \"))\n", + "quantity_book = int(input(\"Enter quality book: \"))\n", + "quantity_keychain = int(input(\"Enter quality keychain: \"))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 10, 'mug': 10, 'hat': 10, 'book': 10, 'keychain': 10}\n" + ] + } + ], + "source": [ + "inventory = {\n", + " \"t-shirt\": quantity_tshirt,\n", + " \"mug\": quantity_mug,\n", + " \"hat\": quantity_hat,\n", + " \"book\": quantity_book,\n", + " \"keychain\": quantity_keychain\n", + "}\n", + "print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Enter product 1 from ['t-shirt', 'mug', 'hat', 'book', 'keychain']: hat\n", + "Enter product 2 from ['t-shirt', 'mug', 'hat', 'book', 'keychain']: book\n", + "Enter product 3 from ['t-shirt', 'mug', 'hat', 'book', 'keychain']: mug\n" + ] + } + ], + "source": [ + "customer_orders = set()\n", + "\n", + "for p in range(3):\n", + " product = input(f\"Enter product {p+1} from {products}: \")\n", + " customer_orders.add(product)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'hat', 'mug', 'book'}\n" + ] + } + ], + "source": [ + "print(customer_orders) " + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n" + ] + } + ], + "source": [ + "number_of_orders = len(customer_orders)\n", + "print(number_of_orders)" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "60.0\n" + ] + } + ], + "source": [ + "percentage_of_products_ordered = (number_of_orders / len(products)) * 100\n", + "print(percentage_of_products_ordered)" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60.0 %\n" + ] + } + ], + "source": [ + "order_status = (number_of_orders, percentage_of_products_ordered)\n", + "print (\"Total Products Ordered:\", number_of_orders)\n", + "print(\"Percentage of Products Ordered:\", percentage_of_products_ordered, \"%\")" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 10, 'mug': 10, 'hat': 10, 'book': 10, 'keychain': 10}\n" + ] + } + ], + "source": [ + "inventory = {\n", + " \"t-shirt\": quantity_tshirt,\n", + " \"mug\": quantity_mug,\n", + " \"hat\": quantity_hat,\n", + " \"book\": quantity_book,\n", + " \"keychain\": quantity_keychain\n", + "}\n", + "print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Invetory after {'t-shirt': -1, 'mug': -1, 'hat': -1, 'book': -1, 'keychain': -1}\n" + ] + } + ], + "source": [ + "for product in inventory:\n", + " inventory[product]= -1\n", + "print(\"Invetory after\", inventory)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "jp-MarkdownHeadingCollapsed": true + }, "source": [ "## Exercise: Managing Customer Orders\n", "\n", @@ -68,7 +260,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.12.7" } }, "nbformat": 4,