Skip to content

Lab-data-strucutre #537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 0 additions & 117 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions lab-python-data-structures (day 1).ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"cells":[{"cell_type":"markdown","metadata":{"tags":[],"id":"qz-oF3Hf_Hc0"},"source":["# Lab | Data Structures"]},{"cell_type":"markdown","metadata":{"id":"Hgadb6DA_Hc6"},"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: <total_products_ordered>\n"," Percentage of Products Ordered: <percentage_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."]},{"cell_type":"code","execution_count":16,"metadata":{"id":"KKGtNBBI_Hc9","executionInfo":{"status":"ok","timestamp":1753170703540,"user_tz":-120,"elapsed":6,"user":{"displayName":"Santiago Larrea","userId":"01956628674237458372"}}},"outputs":[],"source":["products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]"]},{"cell_type":"code","execution_count":17,"metadata":{"id":"Day7le7S_HdB","executionInfo":{"status":"ok","timestamp":1753170704189,"user_tz":-120,"elapsed":4,"user":{"displayName":"Santiago Larrea","userId":"01956628674237458372"}}},"outputs":[],"source":["inventory = {}"]},{"cell_type":"code","execution_count":19,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"JRxknrlA_HdC","executionInfo":{"status":"ok","timestamp":1753170719503,"user_tz":-120,"elapsed":4362,"user":{"displayName":"Santiago Larrea","userId":"01956628674237458372"}},"outputId":"f8b6d90e-faa4-46d7-d63a-c61339440594"},"outputs":[{"output_type":"stream","name":"stdout","text":["Quantity of product t-shirt: 5\n","Quantity of product mug: 5\n","Quantity of product hat: 5\n","Quantity of product book: 5\n","Quantity of product keychain: 5\n","{'t-shirt': 5, 'mug': 5, 'hat': 5, 'book': 5, 'keychain': 5}\n"]}],"source":["555\n","for product in products:\n"," quantity = int(input(f\"Quantity of product {product}: \"))\n"," inventory[product] = quantity\n","\n","print(inventory)"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"EbmBH2lU_HdE"},"outputs":[],"source":["customer_orders = set()"]},{"cell_type":"code","execution_count":20,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"y3EtET7n_HdE","executionInfo":{"status":"ok","timestamp":1753170730527,"user_tz":-120,"elapsed":7594,"user":{"displayName":"Santiago Larrea","userId":"01956628674237458372"}},"outputId":"bf735981-ea36-4e5b-90e6-933e0f1fd082"},"outputs":[{"output_type":"stream","name":"stdout","text":["You have to choose three products\n","Which of this products ['t-shirt', 'mug', 'hat', 'book', 'keychain'] do you want to choose?: hat\n","Which of this products ['t-shirt', 'mug', 'hat', 'book', 'keychain'] do you want to choose?: mug\n","Which of this products ['t-shirt', 'mug', 'hat', 'book', 'keychain'] do you want to choose?: book\n","Your porducts are {'hat', 'book', 'mug'}\n"]}],"source":["print(\"You have to choose three products\")\n","trials = 0\n","while trials < 3:\n"," answer = input(f\"Which of this products {products} do you want to choose?: \")\n"," if answer in products:\n"," customer_orders.add(answer)\n"," trials += 1\n"," else:\n"," print(f\"Your answer {answer} is not in {products}\")\n","\n","\n","print(f\"Your porducts are {customer_orders}\")"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"FqA8RPN6_HdG","executionInfo":{"status":"ok","timestamp":1753170189871,"user_tz":-120,"elapsed":27,"user":{"displayName":"Santiago Larrea","userId":"01956628674237458372"}},"outputId":"8acf1a9c-c5eb-42cd-8636-a5f598fdc16f"},"outputs":[{"output_type":"stream","name":"stdout","text":["```\n","Order Statistics\n","Total Products Ordered: 3\n","Percentage of Products Ordered:60.0%\n","```\n"]}],"source":["total_products_ordered = len(customer_orders)\n","\n","percentage = len(customer_orders)/len(products) * 100\n","\n","print(\"```\")\n","\n","print(\"Order Statistics\")\n","print(f\"Total Products Ordered: {total_products_ordered}\")\n","print(f\"Percentage of Products Ordered:{percentage}%\")\n","print(\"```\")\n"]},{"cell_type":"code","execution_count":21,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"xwrVgT7e_HdH","executionInfo":{"status":"ok","timestamp":1753170737232,"user_tz":-120,"elapsed":26,"user":{"displayName":"Santiago Larrea","userId":"01956628674237458372"}},"outputId":"52df1ede-f4a1-4e74-863c-7f38ef75939d"},"outputs":[{"output_type":"stream","name":"stdout","text":["{'hat', 'book', 'mug'}\n","t-shirt:5\n","mug:4\n","hat:4\n","book:4\n","keychain:5\n"]}],"source":["for key in customer_orders:\n"," inventory[key] -= 1\n","\n","print(customer_orders)\n","\n","for key, values in inventory.items():\n"," print(f\"{key}:{values}\")"]}],"metadata":{"kernelspec":{"display_name":"Python 3","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.13.0"},"colab":{"provenance":[]}},"nbformat":4,"nbformat_minor":0}
76 changes: 0 additions & 76 deletions lab-python-data-structures.ipynb

This file was deleted.