Week 1 exercise

This commit is contained in:
Elijah Rwothoromo
2025-08-05 20:42:50 +03:00
parent 3a042500d7
commit 9da9692a9b
7 changed files with 649 additions and 79 deletions

View File

@@ -32,10 +32,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "33d37cd8-55c9-4e03-868c-34aa9cab2c80",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"4"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Click anywhere in this cell and press Shift + Return\n",
"\n",
@@ -54,7 +65,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "585eb9c1-85ee-4c27-8dc2-b4d8d022eda0",
"metadata": {},
"outputs": [],
@@ -66,10 +77,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "07792faa-761d-46cb-b9b7-2bbf70bb1628",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'bananas'"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# The result of the last statement is shown after you run it\n",
"\n",
@@ -78,10 +100,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "a067d2b1-53d5-4aeb-8a3c-574d39ff654a",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"My favorite fruit is bananas\n"
]
}
],
"source": [
"# Use the variable\n",
"\n",
@@ -90,7 +120,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "4c5a4e60-b7f4-4953-9e80-6d84ba4664ad",
"metadata": {},
"outputs": [],
@@ -116,10 +146,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "8e5ec81d-7c5b-4025-bd2e-468d67b581b6",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"My favorite fruit is anything but bananas\n"
]
}
],
"source": [
"# Then run this cell twice, and see if you understand what's going on\n",
"\n",
@@ -144,10 +182,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "84b1e410-5eda-4e2c-97ce-4eebcff816c5",
"execution_count": 7,
"id": "ce258424-40c3-49a7-9462-e6fa25014b03",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"My favorite fruit is apples\n"
]
}
],
"source": [
"print(f\"My favorite fruit is {favorite_fruit}\")"
]
@@ -165,10 +211,12 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ce258424-40c3-49a7-9462-e6fa25014b03",
"id": "84b1e410-5eda-4e2c-97ce-4eebcff816c5",
"metadata": {},
"outputs": [],
"source": []
"source": [
"print(f\"My favorite fruit is {favorite_fruit} - ok\")"
]
},
{
"cell_type": "markdown",
@@ -221,10 +269,25 @@
"Click in the cell and press the Bin icon if you want to remove it."
]
},
{
"cell_type": "markdown",
"id": "b3b2d1ff-5d2c-47a9-9c1b-90a0cfb89dd9",
"metadata": {},
"source": [
"# This is a heading\n",
"## This is a sub-head\n",
"### And a sub-sub-head\n",
"\n",
"I like Jupyter Lab because it's\n",
"- Easy\n",
"- Flexible\n",
"- Satisfying"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e1586320-c90f-4f22-8b39-df6865484950",
"id": "a365b651-3a34-40ed-8def-df1e6a484b43",
"metadata": {},
"outputs": [],
"source": []
@@ -245,10 +308,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "82042fc5-a907-4381-a4b8-eb9386df19cd",
"execution_count": 1,
"id": "b1b303d9-ce47-4cee-85e9-6416abca7d21",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Guide to Jupyter.ipynb day2 EXERCISE.ipynb troubleshooting.ipynb\n",
"Intermediate Python.ipynb day5.ipynb week1 EXERCISE.ipynb\n",
"\u001b[34mcommunity-contributions\u001b[m\u001b[m diagnostics.py\n",
"day1.ipynb \u001b[34msolutions\u001b[m\u001b[m\n"
]
}
],
"source": [
"# list the current directory\n",
"\n",
@@ -258,13 +332,13 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4fc3e3da-8a55-40cc-9706-48bf12a0e20e",
"id": "18685382-3768-4e00-817b-cc69dd1fb531",
"metadata": {},
"outputs": [],
"source": [
"# ping cnn.com - press the stop button in the toolbar when you're bored\n",
"# ping a website\n",
"\n",
"!ping cnn.com"
"!ping google.com"
]
},
{
@@ -295,7 +369,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "2646a4e5-3c23-4aee-a34d-d623815187d2",
"metadata": {},
"outputs": [],
@@ -313,10 +387,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "6e96be3d-fa82-42a3-a8aa-b81dd20563a5",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|███████████████████████████████████████| 1000/1000 [00:11<00:00, 86.00it/s]\n"
]
}
],
"source": [
"# And now, with a nice little progress bar:\n",
"\n",
@@ -331,10 +413,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "63c788dd-4618-4bb4-a5ce-204411a38ade",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/markdown": [
"# This is a big heading!\n",
"\n",
"- And this is a bullet-point\n",
"- So is this\n",
"- Me, too!"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# On a different topic, here's a useful way to print output in markdown\n",
"\n",
@@ -372,7 +471,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.11"
"version": "3.13.5"
}
},
"nbformat": 4,