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
178 changes: 148 additions & 30 deletions your-code/challenge-1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# Your code here\n"
"# Your code here\n",
"tup = (\"I\",)"
]
},
{
Expand All @@ -32,11 +33,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"tuple"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"type(tup)"
]
},
{
Expand All @@ -54,13 +67,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"first i create a tup with the elements to add, then i create a temporary tup adding the original tup and the new elements and finally i do a conversion with a function to make a tuple\n"
]
}
],
"source": [
"# Your code here\n",
"\n",
"# Your explanation here\n"
"new_elements = \"r\", \"o\", \"n\", \"h\", \"a\", \"c\", \"k\"\n",
"temp_tup = list(tup) + list (new_elements)\n",
"new_tup = tuple(temp_tup)\n",
"# Your explanation here\n",
"print(\"first i create a tup with the elements to add, then i create a temporary tup adding the original tup and the new elements and finally i do a conversion with a function to make a tuple\")"
]
},
{
Expand All @@ -80,13 +104,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# Your code here\n",
"\n",
"# Your explanation here\n"
"tup = (\"I\", \"r\", \"o\", \"n\", \"h\", \"a\", \"c\", \"k\")\n",
"# Your explanation here\n",
"#re assinging, because we need to cast like the previous exercise"
]
},
{
Expand All @@ -104,11 +129,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"# Your code here\n"
"# Your code here\n",
"tup1 = tup[0:4]\n",
"tup2 = tup[4:]"
]
},
{
Expand All @@ -122,11 +149,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"('I', 'r', 'o', 'n', 'h', 'a', 'c', 'k')"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"tup3 = tup1 + tup2\n",
"tup3"
]
},
{
Expand All @@ -138,11 +178,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"lentup1 = len(tup1)\n",
"lentup2 = len(tup2)\n",
"lenboth = lentup1 + lentup2\n",
"lentup3 = len(tup3)\n",
"\n",
"lenboth==lentup3"
]
},
{
Expand All @@ -154,11 +211,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"4"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"tup3.index(\"h\")"
]
},
{
Expand All @@ -178,11 +247,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"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",
"\n",
"for i in letters:\n",
" if i in tup3:\n",
" print(\"True\")\n",
" else:\n",
" print (\"False\")"
]
},
{
Expand All @@ -203,12 +291,42 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a appears 1 times\n",
"b does not appear\n",
"c appears 1 times\n",
"d does not appear\n",
"e does not appear\n"
]
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"letters = [\"a\", \"b\", \"c\", \"d\", \"e\"]\n",
"\n",
"contador = 0\n",
"\n",
"for i in letters:\n",
" contador = 0\n",
" if i in tup3:\n",
" contador +=1\n",
" print(i, \"appears\", contador, \"times\")\n",
" else:\n",
" print (i, \"does not appear\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -227,7 +345,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.11.3"
},
"toc": {
"base_numbering": 1,
Expand Down
Loading