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
174 changes: 144 additions & 30 deletions lab-tuple-set-dict/your-code/challenge-1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# Your code here\n"
"# Your code here\n",
"tup=(\"I\",)\n"
]
},
{
Expand All @@ -33,11 +34,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"tuple"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"type(tup)\n"
]
},
{
Expand All @@ -55,13 +68,34 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('I', 'r', 'o', 'n', 'h', 'a', 'c', 'k')\n"
]
}
],
"source": [
"# Your code here\n",
"tup1=(\"I\",)\n",
"tup1=tup1+(\"r\", \"o\", \"n\", \"h\", \"a\", \"c\", \"k\",)\n",
"print(tup1)\n",
"\n",
"# Your explanation here\n"
"#creo que otro médtodo sería\n",
"#tup1=(\"I\",)\n",
"#list1 = list(tup1)\n",
"#list1.append(\"r\")\n",
"#tup1= tuple(list1)\n",
"#print(tup1)\n",
"\n",
"\n",
"# Your explanation here\n",
"#Por lo que aprendí no se puede usar el comando append (en tuplas), entonces utilice los comandos para concatenar\n",
"#Al concatener se debe agregar una compa entre cda valor.\n"
]
},
{
Expand All @@ -85,7 +119,8 @@
"source": [
"# Your code here\n",
"\n",
"# Your explanation here\n"
"# Your explanation here\n",
"#Por lo que aprendí las tuplas son inmutables, por lo que no se pueden cambiar.\n"
]
},
{
Expand All @@ -103,11 +138,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 22,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('I', 'r', 'o', 'n')\n",
"('h', 'a', 'c', 'k')\n"
]
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"tup2 = tup1[:4]\n",
"tup3 = tup1[-4:]\n",
"print(tup2)\n",
"print(tup3)\n",
"\n"
]
},
{
Expand All @@ -121,11 +170,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 24,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('I', 'r', 'o', 'n', 'h', 'a', 'c', 'k')\n",
"True\n"
]
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"tup4=tup2+tup3\n",
"print(tup4)\n",
"print(tup1==tup4)"
]
},
{
Expand All @@ -137,11 +198,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 29,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"len(tup2)+len(tup3)==len(tup4)"
]
},
{
Expand All @@ -153,11 +226,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 33,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"4"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"tup4.index(\"h\")"
]
},
{
Expand All @@ -177,11 +262,26 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 36,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n",
"False\n",
"True\n",
"False\n",
"False\n"
]
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"letters = [\"a\", \"b\", \"c\", \"d\", \"e\"]\n",
"for letter in letters:\n",
" print(letter in tup4)\n"
]
},
{
Expand All @@ -195,17 +295,31 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 40,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"0\n",
"1\n",
"0\n",
"0\n"
]
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"for letter in letters:\n",
" print(tup4.count(letter))\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -219,9 +333,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
"version": "3.9.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Loading