Skip to content

Add additional exercises on list operations : insert, pop, and clear #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
add additional items to lists exercise
  • Loading branch information
shivapbhusal committed Sep 6, 2020
commit d2948245d5970094de7a0f322c09eb2e20d16a95
82 changes: 81 additions & 1 deletion notebooks/beginner/exercises/lists_exercise.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,86 @@
"print(my_list)\n",
"assert my_list == [14, 12, 6.2, 6, 5, 1, 0.9, 0]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 4. Remove items from right "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"my_list = [1, 2, 3]\n",
"my_list.____\n",
"my_list.____"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"assert my_list == [1]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 5. Insert an item at a given position"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"my_list = ['I', 'am', 'Python']\n",
"#Let's insert an item after 'am'\n",
"my_list.____(____, ____)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"assert my_list = ['I', 'am', 'learning', 'Python']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 6. Remove all items from a list"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"my_list = [1, 2, 3]\n",
"my_list.____"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"assert my_list == []"
]
}
],
"metadata": {
Expand All @@ -141,7 +221,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.4"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy