Skip to content
Open
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
166 changes: 164 additions & 2 deletions lab-python-data-structures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,173 @@
"\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": [
"# This is Kyle Solving the Lab"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"products=[\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"inventory={}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Ask for product inventory\n",
"inventory[\"t-shirt\"] = int(input(\"Enter the quantity of t-shirt: \"))\n",
"inventory[\"mug\"] = int(input(\"Enter the quantity of mug: \"))\n",
"inventory[\"hat\"] = int(input(\"Enter the quantity of hat: \"))\n",
"inventory[\"book\"] = int(input(\"Enter the quantity of book: \"))\n",
"inventory[\"keychain\"] = int(input(\"Enter the quantity of keychain: \"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"customer_orders=set()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Ask for orders\n",
"product_order_1 = input(\"Enter the first product: \")\n",
"product_order_2 = input(\"Enter the second product: \")\n",
"product_order_3 = input(\"Enter the third product: \")\n",
"customer_orders.add(product_order_1)\n",
"customer_orders.add(product_order_2)\n",
"customer_orders.add(product_order_3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(customer_orders)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"percentage_ordered = (len(customer_orders) / len(products)) * 100\n",
"print(f\"percentage of products ordered: {percentage_ordered}%\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"order_status=(total_products_ordered, percentage_ordered)\n",
"print(order_status)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Memory update\n",
"inventory[product_order_1] = inventory[product_order_1] - 1\n",
"inventory[product_order_2] = inventory[product_order_2] - 1\n",
"inventory[product_order_3] = inventory[product_order_3] - 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Inventory update\n",
"print(f\"t-shirt: {inventory['t-shirt']}\")\n",
"print(f\"mug: {inventory['mug']}\")\n",
"print(f\"hat: {inventory['hat']}\")\n",
"print(f\"book: {inventory['book']}\")\n",
"print(f\"keychain: {inventory['keychain']}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -68,7 +230,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.10.4"
}
},
"nbformat": 4,
Expand Down