lecture as finished

This commit is contained in:
Andrew Straw 2024-11-25 07:21:30 +01:00
parent 153d998716
commit eb5db8a689
2 changed files with 4684 additions and 81 deletions

View file

@ -13,9 +13,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Speedrun: command line treasure hunt (schnitzeljagd)\n",
"# Speedrun: command line interface (CLI) treasure hunt (schnitzeljagd)\n",
"\n",
"We will do a quick speedrun of the schnitzeljagd exercise starting with `ssh your-user-name@python-course.strawlab.org`."
"We will do a quick speedrun of the schnitzeljagd exercise starting with `ssh your-user-name@python-course.strawlab.org`.\n",
"\n",
"Discussion: why CLI Python?"
]
},
{
@ -29,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@ -47,7 +49,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@ -56,11 +58,45 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"This was printed from a method inside the class.\n"
]
}
],
"source": [
"x.my_method()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"x.my_method()"
"y = MyClass()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"This was printed from a method inside the class.\n"
]
}
],
"source": [
"y.my_method()"
]
},
{
@ -82,9 +118,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"My variable is foo.\n",
"My variable is bar.\n",
"My variable is zzz.\n"
]
}
],
"source": [
"class MyClass:\n",
" def __init__(self):\n",
@ -115,9 +161,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The insect (species Bombus terrestris) has a mass of 200 milligrams.\n",
"The insect (species Bombus terrestris) has a mass of 205 milligrams.\n",
"The insect (species Apis mellifera) has a mass of 100 milligrams.\n",
"The insect (species Tarantula gigantus) has a mass of 10 grams.\n"
]
}
],
"source": [
"class Insect:\n",
" def __init__(self, species_name, mass, mass_units='milligrams'):\n",
@ -160,18 +217,34 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Bombus terrestris\n"
]
}
],
"source": [
"print(x.species_name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Apis mellifera\n"
]
}
],
"source": [
"print(y.species_name)"
]

File diff suppressed because one or more lines are too long