diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..d786519d Binary files /dev/null and b/.DS_Store differ diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..b0f2cde9 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,13 +50,300 @@ "\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": 27, + "metadata": {}, + "outputs": [], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(products)" + ] + }, + { + "cell_type": "code", + "execution_count": 124, + "metadata": {}, + "outputs": [], + "source": [ + "inventory = {}" + ] + }, + { + "cell_type": "code", + "execution_count": 125, + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Enter the amount of product available: 5\n", + "Enter the amount of product available: 10\n", + "Enter the amount of product available: 15\n", + "Enter the amount of product available: 20\n", + "Enter the amount of product available: 25\n" + ] + } + ], + "source": [ + "inventory[\"tshirt\"] = int(input(\"Enter the amount of product available:\"))\n", + "inventory[\"mug\"] = int(input(\"Enter the amount of product available:\"))\n", + "inventory[\"hat\"] = int(input(\"Enter the amount of product available:\"))\n", + "inventory[\"book\"] = int(input(\"Enter the amount of product available:\"))\n", + "inventory[\"keychain\"] = int(input(\"Enter the amount of product available:\"))" + ] + }, + { + "cell_type": "code", + "execution_count": 126, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'tshirt': 5, 'mug': 10, 'hat': 15, 'book': 20, 'keychain': 25}" + ] + }, + "execution_count": 126, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 102, + "metadata": {}, + "outputs": [], + "source": [ + "customer_order = set()" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "set" + ] + }, + "execution_count": 103, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "type(customer_order)" + ] + }, + { + "cell_type": "code", + "execution_count": 122, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 122, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "total_products_ordered" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Enter the name of the first product you want mug\n", + "Enter the name of the second product you want hat\n", + "Enter the name of the third product you want tshirt\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'mug', 'hat', 'tshirt'}\n" + ] + } + ], + "source": [ + "product1 = input(\"Enter the name of the first product you want\")\n", + "product2 = input(\"Enter the name of the second product you want\")\n", + "product3 = input(\"Enter the name of the third product you want\")\n", + "\n", + "customer_order.add(product1)\n", + "customer_order.add(product2)\n", + "customer_order.add(product3)\n", + "\n", + "print(customer_order)" + ] + }, + { + "cell_type": "code", + "execution_count": 108, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n" + ] + } + ], + "source": [ + "total_products_ordered = len(customer_order)\n", + "print(len(customer_order))" + ] + }, + { + "cell_type": "code", + "execution_count": 109, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Available Products: 75\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 0.04\n" + ] + } + ], + "source": [ + "total_available_products = sum(inventory.values())\n", + "print(\"Total Available Products:\",total_available_products)\n", + "print(\"Total Products Ordered: \", total_products_ordered)\n", + "percentage_ordered = (total_products_ordered / total_available_products)\n", + "print(\"Percentage of Products Ordered:\", percentage_ordered)" + ] + }, + { + "cell_type": "code", + "execution_count": 111, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Products Ordered:: 3\n", + "Total Available Products: 75\n" + ] + } + ], + "source": [ + "order_status = (total_products_ordered, total_available_products)\n", + "print(\"Total Products Ordered::\", order_status[0])\n", + "print(\"Total Available Products:\", order_status[1])" + ] + }, + { + "cell_type": "code", + "execution_count": 121, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "New Updated Inventory for Hat: 12\n", + "New Updated Inventory for Tshirt: 2\n", + "New Updated Inventory for Mug: 7\n" + ] + } + ], + "source": [ + "inventory[\"hat\"] = inventory[\"hat\"] - 1\n", + "print(\"New Updated Inventory for Hat: \", inventory[\"hat\"])\n", + "inventory[\"tshirt\"] = inventory[\"tshirt\"] - 1\n", + "print(\"New Updated Inventory for Tshirt: \", inventory[\"tshirt\"])\n", + "inventory[\"mug\"] = inventory[\"mug\"] - 1\n", + "print(\"New Updated Inventory for Mug: \", inventory[\"mug\"])" + ] + }, + { + "cell_type": "code", + "execution_count": 119, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Updated Inventory: \n", + "T-shirt Inventory: 25\n", + "Mug Inventory: 9\n", + "Hat Inventory: 14\n", + "Book Inventory: 20\n", + "Keychain Inventory: 25\n" + ] + } + ], + "source": [ + "print(\"Total Updated Inventory: \")\n", + "print(\"T-shirt Inventory:\", inventory[\"keychain\"])\n", + "print(\"Mug Inventory:\", inventory[\"mug\"])\n", + "print(\"Hat Inventory:\", inventory[\"hat\"])\n", + "print(\"Book Inventory:\", inventory[\"book\"])\n", + "print(\"Keychain Inventory:\", inventory[\"keychain\"])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "anaconda-panel-2023.05-py310", "language": "python", - "name": "python3" + "name": "conda-env-anaconda-panel-2023.05-py310-py" }, "language_info": { "codemirror_mode": { @@ -68,7 +355,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.11.5" } }, "nbformat": 4,