diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..3229e5b5 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,6 +50,51 @@ "\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": null, + "metadata": {}, + "outputs": [], + "source": [ + "products=[\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory={}\n", + "for product in products:\n", + " quantity = input(f\"Enter the quantity for {product}: \")\n", + " inventory[product] = int(quantity)\n", + "\n", + "customer_orders=set() \n", + "\n", + "while len(customer_orders)<3:\n", + " product=input(\"enter the name of a product you'd like to order: \").strip()\n", + " if product in products:\n", + " customer_orders.add(product)\n", + " else:\n", + " print(\"That's not a valid product. Please choose from the list.\")\n", + " print(\"Available products:\", \", \".join(products))\n", + " \n", + "print(\"customer order: \", customer_orders) \n", + "\n", + "total_products_ordered=len(customer_orders)\n", + "percentage_products_ordered=(total_products_ordered/len(products))*100\n", + "ordered_status=(total_products_ordered, percentage_products_ordered) \n", + "print(\"\"\"Order Statistics:\n", + " Total Products Ordered: \n", + " Percentage of Products Ordered: % \n", + " \"\"\")\n", + "\n", + "for product in customer_orders:\n", + " if product in inventory:\n", + " inventory[product]=max(0, inventory[product]-1)\n", + "print(\"Update inventory: \", inventory) \n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -68,7 +113,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.9" } }, "nbformat": 4,