Skip to content
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.
2,123 changes: 2,123 additions & 0 deletions .ipynb_checkpoints/1.1_data_structures-checkpoint.ipynb

Large diffs are not rendered by default.

Empty file added file1.py
Empty file.
Empty file added file2.py
Empty file.
Empty file added file3.py
Empty file.
Empty file added file4.py
Empty file.
135 changes: 132 additions & 3 deletions lab-python-data-structures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,142 @@
"\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": 14,
"metadata": {},
"outputs": [],
"source": [
" products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"inventory = {} "
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"Please enter the quantity for t-shirt: 4\n",
"Please enter the quantity for mug: 9\n",
"Please enter the quantity for hat: 6\n",
"Please enter the quantity for book: 7\n",
"Please enter the quantity for keychain: 8\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'t-shirt': 4, 'mug': 9, 'hat': 6, 'book': 7, 'keychain': 8}\n"
]
}
],
"source": [
"for product in products:\n",
" key_input = input(f\"Please enter the quantity for {product}: \")\n",
" inventory[product] = int(key_input)\n",
" \n",
"print(inventory)\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"Please enter name of items from the products list ['t-shirt', 'mug', 'hat', 'book', 'keychain']: book\n",
"Please enter name of items from the products list ['t-shirt', 'mug', 'hat', 'book', 'keychain']: mug\n",
"Please enter name of items from the products list ['t-shirt', 'mug', 'hat', 'book', 'keychain']: hat\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'book', 'hat', 'mug'}\n"
]
}
],
"source": [
"customer_orders = set()\n",
"products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n",
"\n",
"for i in range(3):\n",
" product = input(f\"Please enter name of items from the products list {products}: \") \n",
" if product in products: \n",
" customer_orders.add(product)\n",
" else:\n",
" print(f\"{product} is not in the product list. Please try again.\")\n",
"\n",
"print(customer_orders) \n",
" "
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"import statistics"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "unmatched ')' (180260199.py, line 5)",
"output_type": "error",
"traceback": [
" \u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[13]\u001b[39m\u001b[32m, line 5\u001b[39m\n\u001b[31m \u001b[39m\u001b[31mprint)('Ordered Statistics:')\u001b[39m\n ^\n\u001b[31mSyntaxError\u001b[39m\u001b[31m:\u001b[39m unmatched ')'\n"
]
}
],
"source": [
"customer_set = {'book', 'hat', 'mug'}\n",
"product_orders = {'t-shirt': 4, 'mug': 9, 'hat': 6, 'book': 7, 'keychain': 8}\n",
"total_products_ordered = sum(product_orders.values())\n",
"\n",
"print)('Ordered Statistics:')\n",
"print(total_products_ordered)\n",
"print(sum(products_ordered.values)/total_products_ordered))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "python-starter",
"language": "python",
"name": "python3"
"name": "conda-env-python-starter"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -68,7 +197,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.11.13"
}
},
"nbformat": 4,
Expand Down