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
184 changes: 182 additions & 2 deletions lab-python-data-structures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,186 @@
"# Lab | Data Structures "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"#n1 list\n",
"products= [\"t-shirt\",\"mug\",\"hat\",\"book\",\"keychain\"]\n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"#n2 empty dictionary\n",
"inventory= {} "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"#3 fill inventory\n",
"inventory['t-shirt']= int(input('numbers of t-shirts: '))\n",
"inventory['mug']= int(input('numbers of mug: '))\n",
"inventory['hat']= int(input('numbers of hat: '))\n",
"inventory['book']= int(input ('numbers of book: '))\n",
"inventory['keychain']= int(input ('numbers of keychain: ')) \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'t-shirt': 6, 'mug': 3, 'hat': 2, 'book': 5, 'keychain': 4}\n"
]
}
],
"source": [
"print (inventory)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
"#4 empty set\n",
"customers_orders= set ()"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"#5\n",
"product1= input(\"primer producto: \") \n",
"customers_orders.add(product1) \n",
"product2= input(\"segundo producto: \") \n",
"customers_orders.add(product2)\n",
"product3= input(\"tercer producto: \")\n",
"customers_orders.add(product3)\n",
"\n",
" \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'hat', 'mug', 't-shirt'}\n"
]
}
],
"source": [
"#6 realizar el print\n",
"print (customers_orders)"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
"total_products_ordened= len(customers_orders)\n",
"percent_products_ordened= total_products_ordened/len(products)*100"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [],
"source": [
"order_status=(total_products_ordened, percent_products_ordened)\n"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Order Statistics:\n",
"total products ordened 3\n",
"percent of products ordened 60.0\n"
]
}
],
"source": [
"print(\"Order Statistics:\")\n",
"print(\"total products ordened\",order_status[0])\n",
"print(\"percent of products ordened\",order_status[1]) "
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'t-shirt': 4, 'mug': 1, 'hat': 0, 'book': 3, 'keychain': 2}\n"
]
}
],
"source": [
"#9 modificar inventario\n",
"inventory['t-shirt']-=1 \n",
"inventory['mug']-=1\n",
"inventory['hat']-=1\n",
"inventory['book']-=1\n",
"inventory['keychain']-=1\n",
"print(inventory)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -54,7 +234,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "base",
"language": "python",
"name": "python3"
},
Expand All @@ -68,7 +248,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down