diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..1ccb025f 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,199 @@ "\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": [], + "source": [ + "#1\n", + "products = (\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\")\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "#2 \n", + "inventory = { }" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 45, 'mug': 56, 'hat': 33, 'book': 41, 'keychain': 70}\n" + ] + } + ], + "source": [ + "#3 \n", + "q1 = int(input(\"Quantity of t-shirt: \"))\n", + "inventory['t-shirt'] = q1\n", + "\n", + "q2 = int(input(\"Quantity of mug: \"))\n", + "inventory['mug'] = q2\n", + "\n", + "q3 = int(input(\"Quantity of hat: \"))\n", + "inventory['hat'] = q3\n", + "\n", + "q4 = int(input(\"Quantity of book: \"))\n", + "inventory['book'] = q4\n", + "\n", + "q5 = int(input(\"Quantity of keychain: \"))\n", + "inventory['keychain'] = q5\n", + "\n", + "print(inventory)\n", + "\n", + "#for i range(5)\n", + " #" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "#4.\n", + "customer_orders = set()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt', 'hat', 'kechain'}\n" + ] + } + ], + "source": [ + "#5. \n", + "o1 = input(\"Enter Product 1 to Order: \")\n", + "customer_orders.add(o1)\n", + "\n", + "o2 = input(\"Enter Product 2to Order: \")\n", + "customer_orders.add(o2)\n", + "\n", + "o3 = input(\"Enter Product 3 to Order: \")\n", + "customer_orders.add(o3)\n", + "\n", + "#6\n", + "print(customer_orders)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "60.0 %\n" + ] + } + ], + "source": [ + "#7. total number of products in the customer order set\n", + "print(len(customer_orders))\n", + "\n", + "#Percentage of Products Ordered from the inventory\n", + "percentage_po = len(customer_orders)*100/len(inventory)\n", + "print(percentage_po, '%')\n", + "\n", + "#Store these statistics in a tuple called `order_status`\n", + "\n", + "order_status = (len(customer_orders), percentage_po)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Order Statistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60.0 %\n" + ] + } + ], + "source": [ + "#8. Print order status\n", + "\n", + "#print(order_status)\n", + "print('Order Statistics:')\n", + "print('Total Products Ordered:', len(customer_orders))\n", + "print('Percentage of Products Ordered:', (percentage_po),'%')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#9.\n", + "\n", + "for product in inventory:\n", + " inventory[product] = inventory[product] - 1\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 43, 'mug': 55, 'hat': 31, 'book': 40, 'keychain': 69}\n" + ] + } + ], + "source": [ + "#10. \n", + "\n", + "print(inventory)" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -68,7 +256,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.2" } }, "nbformat": 4,