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
32 changes: 32 additions & 0 deletions your-code/Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
219 changes: 182 additions & 37 deletions your-code/challenge-1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,28 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# Your code here"
"tup=(\"I\",)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('I',)\n"
]
}
],
"source": [
"print(tup)"
]
},
{
Expand All @@ -33,11 +50,23 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 13,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"tuple"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here"
"type(tup)\n",
"\n"
]
},
{
Expand All @@ -55,20 +84,30 @@
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"execution_count": 14,
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('r', 'o', 'n', 'h', 'a', 'c', 'k')\n"
]
}
],
"source": [
"# Your code here\n",
"tup = (\"r\", \"o\", \"n\", \"h\", \"a\", \"c\", \"k\")\n",
"\n",
"# Your explanation here\n"
"print(tup)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### How about re-assign a new value to an existing tuple?\n",
"\n",
"\n",
"Re-assign the following elements to `tup`. Are you able to do it? Explain.\n",
"\n",
Expand All @@ -79,13 +118,21 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 15,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('I', 'r', 'o', 'n', 'h', 'a', 'c', 'k')\n"
]
}
],
"source": [
"# Your code here\n",
"tup = (\"I\", \"r\", \"o\", \"n\", \"h\", \"a\", \"c\", \"k\")\n",
"\n",
"# Your explanation here\n"
"print (tup)"
]
},
{
Expand All @@ -103,11 +150,23 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('I', 'r', 'o', 'n')\n",
"('h', 'a', 'c', 'k')\n"
]
}
],
"source": [
"# Your code here\n"
"tup1=(\"I\", \"r\", \"o\", \"n\")\n",
"tup2=(\"h\", \"a\", \"c\", \"k\")\n",
"print(tup1)\n",
"print(tup2)"
]
},
{
Expand All @@ -121,11 +180,21 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('I', 'r', 'o', 'n', 'h', 'a', 'c', 'k')\n"
]
}
],
"source": [
"# Your code here\n"
"tup3 = tup1 + tup2 \n",
"\n",
"print(tup3)\n"
]
},
{
Expand All @@ -137,11 +206,23 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 18,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"8"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here\n"
"len((tup1)+(tup2))\n",
"len(tup3)"
]
},
{
Expand All @@ -153,11 +234,22 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 19,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'h'"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here"
"tup3[4]"
]
},
{
Expand All @@ -177,11 +269,32 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 20,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a - True\n",
"b - False\n",
"c - True\n",
"d - False\n",
"e - False\n"
]
}
],
"source": [
"# Your code here\n"
"letters = [\"a\", \"b\", \"c\", \"d\", \"e\"]\n",
"\n",
"\n",
"for i in letters:\n",
" if i in tup3:\n",
" print(i,\"-\", True)\n",
" else:\n",
" print(i,\"-\",False)\n",
" \n",
"\n"
]
},
{
Expand All @@ -195,11 +308,27 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 21,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"0\n",
"1\n",
"0\n",
"0\n"
]
}
],
"source": [
"# Your code here\n"
"numbers_letters = []\n",
"\n",
"for letter in letters:\n",
" print(tup3.count(letter))\n",
" "
]
},
{
Expand All @@ -211,12 +340,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'range'>\n"
]
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"range(10,20)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -235,7 +380,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.6"
}
},
"nbformat": 4,
Expand Down
Loading