diff --git a/lab 1 - 14.10.24.ipynb b/lab 1 - 14.10.24.ipynb new file mode 100644 index 0000000..e7700df --- /dev/null +++ b/lab 1 - 14.10.24.ipynb @@ -0,0 +1,407 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 29, + "id": "f5a7d6ba-d6ce-48a9-a22e-2e3b0f06d512", + "metadata": {}, + "outputs": [], + "source": [ + "# EXERCISE: MANAGING CUSTOMER ORDERS \n", + "# Exercise 1." + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "59020b39-0e87-401b-abe5-72b68b3ddb22", + "metadata": {}, + "outputs": [], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "edf5b389-c916-4e34-b205-79e44c80f82c", + "metadata": {}, + "outputs": [], + "source": [ + "#Exercise 2." + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "1dd5888d-3c7d-4352-85c0-97b842896920", + "metadata": {}, + "outputs": [], + "source": [ + "inventory = {}" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "fb8f1e27-d619-472c-abdc-c852e6939216", + "metadata": {}, + "outputs": [], + "source": [ + "#Exercise 3" + ] + }, + { + "cell_type": "code", + "execution_count": 211, + "id": "7806be13-9072-4c4e-a578-9ccb44eb753b", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "please enter t-shirt 5\n", + "please enter mug 6\n", + "please enter hat 7\n", + "please enter book 8\n", + "please enter keychain 9\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 5, 'mug': 6, 'hat': 7, 'book': 8, 'keychain': 9}\n" + ] + } + ], + "source": [ + "for product in products:\n", + " inventory[product] = int(input(f'please enter {product}'))\n", + "print(inventory)\n", + "\n", + " \n", + " \n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "id": "43a40b86-8f12-4001-be6e-e3fa58cc28fb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['t-shirt', 'mug', 'hat', 'book', 'keychain']" + ] + }, + "execution_count": 71, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "products" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "id": "efa15a5c-637d-4ed0-abb4-39a4cc1f9f6e", + "metadata": {}, + "outputs": [], + "source": [ + "customer_orders = set()" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "id": "fe2c56b4-bd3c-4ed9-9cdf-14df31f99f0a", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Enter the first product: mug\n" + ] + } + ], + "source": [ + "product1 = input('Enter the first product:')" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "id": "80067f8a-2a78-4d3e-a51c-cb68b224988e", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Enter the second product: hat\n" + ] + } + ], + "source": [ + "product2 = input('Enter the second product:')" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "2e08d23b-6be9-4e0d-9342-5bc6cae7a197", + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Enter the second product: book\n" + ] + } + ], + "source": [ + "product3 = input('Enter the third product:')" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "id": "9995386b-ef8a-49b2-816b-713795c0ec8a", + "metadata": {}, + "outputs": [], + "source": [ + "customer_orders.add(product1)\n", + "customer_orders.add(product2)\n", + "customer_orders.add(product3)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "id": "080b88c7-fcd5-4574-a770-ae1ceceeb380", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'book', 'hat', 'mug'}" + ] + }, + "execution_count": 85, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "customer_orders" + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "id": "c4de9d00-b00a-4d39-8937-961572223bfc", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n" + ] + } + ], + "source": [ + "total_products = len(customer_orders)\n", + "print(total_products)" + ] + }, + { + "cell_type": "code", + "execution_count": 113, + "id": "aaace79c-6ce6-474b-ba25-2409bd4742ad", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5\n" + ] + } + ], + "source": [ + "products_available = len(inventory)\n", + "print(products_available)" + ] + }, + { + "cell_type": "code", + "execution_count": 123, + "id": "6c407f51-4cd2-4cfb-aaa7-12e2c08fcd0f", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The percentage is 60.0 %\n" + ] + } + ], + "source": [ + "percentage_products = total_products / products_available *100\n", + "print(f'The percentage is {percentage_products} %')" + ] + }, + { + "cell_type": "code", + "execution_count": 133, + "id": "c9a132fc-49b2-4b8d-88c1-ca8fa6275285", + "metadata": {}, + "outputs": [], + "source": [ + "order_status = (total_products , percentage_products)" + ] + }, + { + "cell_type": "code", + "execution_count": 135, + "id": "6813e7b3-22eb-4d3b-aabd-c8ee3aa42368", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(3, 60.0)" + ] + }, + "execution_count": 135, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "order_status" + ] + }, + { + "cell_type": "code", + "execution_count": 225, + "id": "e8fdab60-1377-4f6b-8d16-0f191b9843ca", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " Order Statistics: \n", + " Total products ordered: 3 \n", + " Percentage of products ordered: 60.0\n" + ] + } + ], + "source": [ + "order_statistics = (f'\\n Order Statistics: \\n Total products ordered: {total_products} \\n Percentage of products ordered: {percentage_products}')\n", + "print(order_statistics)" + ] + }, + { + "cell_type": "code", + "execution_count": 165, + "id": "47a519ad-56ab-44f3-8ece-89f9f3fdf533", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'t-shirt': 5, 'mug': 6, 'hat': 7, 'book': 8, 'keychain': 9}" + ] + }, + "execution_count": 165, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 229, + "id": "437d5117-a7b8-47e4-a5cf-c87bc541c829", + "metadata": {}, + "outputs": [], + "source": [ + "for product in inventory:\n", + " if inventory[product] > 0: \n", + " inventory[product] -= 1\n", + " else:\n", + " print(f'There are not enough inventory for {product}')\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 227, + "id": "774ba31f-fa7e-42ef-99b5-4748606c34f2", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 4, 'mug': 5, 'hat': 6, 'book': 7, 'keychain': 8}\n", + "{'t-shirt': 4, 'mug': 5, 'hat': 6, 'book': 7, 'keychain': 8}\n", + "{'t-shirt': 4, 'mug': 5, 'hat': 6, 'book': 7, 'keychain': 8}\n", + "{'t-shirt': 4, 'mug': 5, 'hat': 6, 'book': 7, 'keychain': 8}\n", + "{'t-shirt': 4, 'mug': 5, 'hat': 6, 'book': 7, 'keychain': 8}\n" + ] + } + ], + "source": [ + "for key,values in inventory.items():\n", + " print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "87f76599-154b-4a1b-8250-27779c6f8709", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.12.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb deleted file mode 100644 index 5b3ce9e..0000000 --- a/lab-python-data-structures.ipynb +++ /dev/null @@ -1,76 +0,0 @@ -{ - "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 -}