Skip to content

ds lab completed #487

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
98 changes: 96 additions & 2 deletions lab-python-data-structures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,105 @@
"\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": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'t-shirt': 10, 'mug': 20, 'hat': 30, 'book': 40, 'keychain': 50}\n"
]
}
],
"source": [
"products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n",
"inventory = {}\n",
"for quan_prod in products:\n",
" quantity = int(input(f\"Enter the quantity of {products} available in the inventory:\"))\n",
" inventory[quan_prod] = quantity\n",
"print(inventory)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'3', '2', '1'}\n"
]
}
],
"source": [
"customer_order = set()\n",
"for pro in range(3):\n",
" product_name = input(\"Enter the name of three products that a customer wants to order: \")\n",
" customer_order.add(product_name)\n",
"print(customer_order)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3\n",
"(3, 60.0)\n",
"Total Products Ordered: 3\n",
"Percentage of Products Ordered:60.0%\n"
]
}
],
"source": [
"total_products_ordered = len(customer_order)\n",
"print(total_products_ordered)\n",
"percentage_products_ordered = (total_products_ordered / len(products))*100\n",
"order_status = (total_products_ordered,percentage_products_ordered)\n",
"print(order_status)\n",
"print(\"Total Products Ordered:\", order_status[0])\n",
"print(f\"Percentage of Products Ordered:{order_status[1]}%\")"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"t-shirt 3\n",
"mug 13\n",
"hat 23\n",
"book 33\n",
"keychain 43\n",
"{'t-shirt': 2, 'mug': 12, 'hat': 22, 'book': 32, 'keychain': 42}\n"
]
}
],
"source": [
"for key, value in inventory.items():\n",
" inventory[key] = (value - 1)\n",
" print(key,value)\n",
"print(inventory)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -68,7 +162,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down