150 lines
2.8 KiB
Plaintext
150 lines
2.8 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 1. Fill the missing pieces\n",
|
|
"Fill the `____` parts of the code below."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Let's create an empty list\n",
|
|
"my_list = ____\n",
|
|
"\n",
|
|
"# Let's add some values\n",
|
|
"my_list.____('Python')\n",
|
|
"my_list.____('is ok')\n",
|
|
"my_list.____('sometimes')\n",
|
|
"\n",
|
|
"# Let's remove 'sometimes'\n",
|
|
"my_list.____('sometimes')\n",
|
|
"\n",
|
|
"# Let's change the second item\n",
|
|
"my_list[____] = 'is neat'"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"editable": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Let's verify that it's correct\n",
|
|
"assert my_list == ['Python', 'is neat']"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 2. Create a new list without modifiying the original one\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"editable": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"original = ['I', 'am', 'learning', 'hacking', 'in']"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Your implementation here\n",
|
|
"modified = "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"editable": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"assert original == ['I', 'am', 'learning', 'hacking', 'in']\n",
|
|
"assert modified == ['I', 'am', 'learning', 'lists', 'in', 'Python']"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 3. Create a merged sorted list"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"editable": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"list1 = [6, 12, 5]\n",
|
|
"list2 = [6.2, 0, 14, 1]\n",
|
|
"list3 = [0.9]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Your implementation here\n",
|
|
"my_list = "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"editable": false,
|
|
"scrolled": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"print(my_list)\n",
|
|
"assert my_list == [14, 12, 6.2, 6, 5, 1, 0.9, 0]"
|
|
]
|
|
}
|
|
],
|
|
"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.5.4"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|