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
150 changes: 28 additions & 122 deletions your-code/.ipynb_checkpoints/challenge-1-checkpoint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -34,23 +34,11 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tuple"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"# Your code here\n",
"type(tup)"
"# Your code here\n"
]
},
{
Expand All @@ -68,26 +56,13 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'tuple' object has no attribute 'append'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-3-79d5a2bcc9c1>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# Your code here\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mtup\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"r\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;31m# Your explanation here\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;31m# tuple is immutable\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mAttributeError\u001b[0m: 'tuple' object has no attribute 'append'"
]
}
],
"outputs": [],
"source": [
"# Your code here\n",
"tup.append(\"r\")\n",
"# Your explanation here\n",
"# tuple is immutable"
"\n",
"# Your explanation here\n"
]
},
{
Expand All @@ -110,9 +85,8 @@
"outputs": [],
"source": [
"# Your code here\n",
"tup[0] = \"r\"\n",
"# Your explanation here\n",
"# tuple is immutable"
"\n",
"# Your explanation here\n"
]
},
{
Expand All @@ -130,13 +104,11 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Your code here\n",
"tup1 = (\"I\", \"r\", \"o\", \"n\")\n",
"tup2 = (\"h\", \"a\", \"c\", \"k\")"
"# Your code here\n"
]
},
{
Expand All @@ -150,26 +122,11 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('I', 'r', 'o', 'n', 'h', 'a', 'c', 'k')\n",
"('I', 'r', 'o', 'n', 'h', 'a', 'c', 'k')\n",
"True\n"
]
}
],
"outputs": [],
"source": [
"# Your code here\n",
"tup = (\"I\", \"r\", \"o\", \"n\", \"h\", \"a\", \"c\", \"k\")\n",
"tup3 = tup1 + tup2\n",
"print(tup3)\n",
"print(tup)\n",
"print(tup == tup3)"
"# Your code here\n"
]
},
{
Expand All @@ -181,26 +138,11 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4\n",
"8\n",
"8\n",
"8\n"
]
}
],
"outputs": [],
"source": [
"# Your code here\n",
"print(len(tup1))\n",
"print(len(tup3))\n",
"print(len(tup1) + len(tup2))\n",
"print(len(tup3))"
"# Your code here\n"
]
},
{
Expand All @@ -212,24 +154,11 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"# Your code here\n",
"tup3.index(\"h\")\n",
"##It's number 4"
"# Your code here\n"
]
},
{
Expand All @@ -249,33 +178,11 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[True, False, True, False, False]\n"
]
}
],
"outputs": [],
"source": [
"letters = [\"a\", \"b\", \"c\", \"d\", \"e\"]\n",
"\n",
"# Your code here\n",
"# with a for loop\n",
"#for element in letters:\n",
" # if element in tup3:\n",
" # print(True)\n",
" # else:\n",
" # print(False)\n",
"#using a list comprehension\n",
"\n",
"existing_letters = [True if (element in tup3) else False for element in letters ]\n",
"\n",
"#if element in tup3 print(True) else print(False) \n",
"print(existing_letters)\n"
"# Your code here\n"
]
},
{
Expand All @@ -293,14 +200,13 @@
"metadata": {},
"outputs": [],
"source": [
"# Your code here\n",
"\n"
"# Your code here\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -314,9 +220,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.11.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
9 changes: 5 additions & 4 deletions your-code/challenge-1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"metadata": {},
"outputs": [],
"source": [
"# Your code here\n"
"# Your code here\n",
"tup = (\"I\",)"
]
},
{
Expand Down Expand Up @@ -205,7 +206,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -219,9 +220,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
"version": "3.11.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}