Upload files to "/"
This commit is contained in:
139
example.ipynb
Normal file
139
example.ipynb
Normal file
@@ -0,0 +1,139 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6541d0bd-4ae9-4733-809e-b4906d27ed7b",
|
||||
"metadata": {
|
||||
"editable": true,
|
||||
"slideshow": {
|
||||
"slide_type": ""
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"# Introduction to Python\n",
|
||||
"\n",
|
||||
"Welcome to the course notebook.\n",
|
||||
"\n",
|
||||
"In this lesson you will learn:\n",
|
||||
"\n",
|
||||
"- Variables\n",
|
||||
"- Loops\n",
|
||||
"- Functions\n",
|
||||
"- Basic problem solving\n",
|
||||
"\n",
|
||||
"Run each code cell and experiment with the examples."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "a560e020-204c-4edc-92d2-1149d05270a5",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"name = \"Alice\"\n",
|
||||
"age = 21\n",
|
||||
"\n",
|
||||
"print(f\"Hello {name}, you are {age} years old.\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9d40ccd6-428c-4522-8b1a-d37807cde3cd",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Loops\n",
|
||||
"\n",
|
||||
"Loops allow us to repeat actions."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "9272f123-5534-465f-b12e-6a6183d0d895",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for i in range(5):\n",
|
||||
" print(f\"Iteration {i}\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "da7dfea9-60c1-4a2e-b664-a41c0e5aa5f1",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Functions\n",
|
||||
"\n",
|
||||
"Functions help organize code into reusable blocks."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "c3b50329-b0f4-4a60-832d-65b003377838",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def square(x):\n",
|
||||
" return x * x\n",
|
||||
"\n",
|
||||
"square(5)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "87d1c1e8-9cfc-4a0e-8754-5c46f18e4417",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Exercise\n",
|
||||
"\n",
|
||||
"Create a function called `cube(x)` that returns the cube of a number.\n",
|
||||
"\n",
|
||||
"Test it with:\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"cube(3)\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"Expected result:\n",
|
||||
"27"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "06d41b40-c13c-483d-b12e-403fde15d1c8",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def cube(x):\n",
|
||||
" return x ** 3\n",
|
||||
"\n",
|
||||
"cube(3)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"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.11.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Reference in New Issue
Block a user