Skip to content

lab done #457

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
Show file tree
Hide file tree
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
Binary file added .DS_Store
Binary file not shown.
76 changes: 74 additions & 2 deletions lab-python-functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,83 @@
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "2bfa9eb9",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(0, 0.0)\n"
]
}
],
"source": [
"products = ['t-shirt', 'mug', 'hat', 'book', 'keychain']\n",
"customer_orders = set()\n",
"\n",
"def initialize_inventory(products):\n",
" inventory = {}\n",
" for product in products:\n",
" quantity = int(input(f\"How many {product}s do you have? \"))\n",
" inventory[product] = quantity\n",
" return inventory\n",
"\n",
"def get_customer_orders():\n",
" \n",
" customer_orders = set()\n",
"\n",
" condition = \"yes\"\n",
"\n",
" while condition == \"yes\":\n",
" order = input(f'Please enter the name of a product you want to order:')\n",
" customer_orders.add(order)\n",
"\n",
" condition = input('Do you want to add another product (yes/no)?')\n",
"\n",
" return (f'You added following products: {customer_orders}')\n",
"\n",
"def update_inventory(customer_orders, inventory):\n",
" for item in customer_orders:\n",
" if item in inventory:\n",
" inventory[item] -= 1\n",
" return inventory\n",
"\n",
"def calculate_order_statistics(customer_orders, products):\n",
" total = len(customer_orders)\n",
" percentage = (total / len(products)) * 100\n",
" return total, percentage\n",
" \n",
"\n",
"stats = calculate_order_statistics(customer_orders, products)\n",
"print (stats)\n",
"\n",
"def print_order_statistics(order_statistics):\n",
" print (f'Order Statistics: Total Products Ordered: {order_status[0]},Percentage of Products Ordered: {order_status[1]}')\n",
"\n",
"def print_updated_inventory(inventory):\n",
" print ('Updated inventory:', inventory)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9351864a",
"metadata": {},
"outputs": [],
"source": [
"\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "base",
"language": "python",
"name": "python3"
},
Expand All @@ -61,7 +133,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down