Skip to content

lab 1 OK #527

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
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
77 changes: 77 additions & 0 deletions lab-python-data-structures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,83 @@
"\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": [
"#1 List \n",
"products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n",
"\n",
"\n",
"#2 Dictionary\n",
"inventory = {}\n",
"\n",
"#3 \n",
"inventory[\"t-shirt\"] = int(input(\"Enter t-shirt quantity: \"))\n",
"inventory[\"mug\"] = int(input(\"Enter mug quantity: \"))\n",
"inventory[\"hat\"] = int(input(\"Enter hat quantity: \"))\n",
"inventory[\"book\"] = int(input(\"Enter book quantity: \"))\n",
"inventory[\"keychain\"] = int(input(\"Enter keychain quantity: \"))\n",
"\n",
"print(inventory)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#4\n",
"customer_orders = set()\n",
"\n",
"#5\n",
"product_name = input(\"Enter the name of the product that you order: \")\n",
"customer_orders.add(product_name)\n",
"\n",
"product_name = input(\"Enter the name of the product that you order: \")\n",
"customer_orders.add(product_name)\n",
"\n",
"product_name = input(\"Enter the name of the product that you order: \")\n",
"customer_orders.add(product_name)\n",
"\n",
"#6\n",
"print(\"Products in customer order: \", customer_orders) "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#7\n",
"total_products_ordered = len(customer_orders)\n",
"percentage_ordered = (total_products_ordered/len(products)) * 100\n",
"\n",
"order_stats = (total_products_ordered, percentage_ordered)\n",
"\n",
"#8\n",
"print(\"Order Statistics: \")\n",
"print(f\"Total Products Ordered: {len(customer_orders)}\")\n",
"print(f\"Percentage of Products Ordered: {percentage_ordered}%\")\n",
"\n",
"\n",
"#9\n",
"list(product_name)[0]\n",
"inventory[product_name] -= 1\n",
"\n",
"list(product_name)[1]\n",
"inventory[product_name] -= 1\n",
"\n",
"list(product_name)[2]\n",
"inventory[product_name] -= 1\n",
"\n",
"print(inventory)"
]
}
],
"metadata": {
Expand Down