new exercise

This commit is contained in:
Andrew Straw 2024-11-15 09:44:17 +01:00
parent e48b980941
commit cff8bbd085
2 changed files with 238 additions and 0 deletions

View file

@ -39,6 +39,7 @@ http://pythontutor.com/
| exercise-03 | 2024-10-30 |
| exercise-04 | 2024-11-06 |
| exercise-05 | 2024-11-13 |
| exercise-06 | 2024-11-20 |
## Submitting assignments

View file

@ -0,0 +1,237 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "abe9babf",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "code",
"checksum": "51e42914efcd3e06e0d245a8fd0580fc",
"grade": false,
"grade_id": "cell-05142c09f787bba0",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"# You must run this cell, but you can ignore its contents.\n",
"\n",
"import hashlib\n",
"\n",
"def ads_hash(ty):\n",
" \"\"\"Return a unique string for input\"\"\"\n",
" ty_str = str(ty).encode()\n",
" m = hashlib.sha256()\n",
" m.update(ty_str)\n",
" return m.hexdigest()[:10]"
]
},
{
"cell_type": "markdown",
"id": "4be5f20b-f850-4267-b57c-0cc8aee0d30a",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "markdown",
"checksum": "6951a882523f63c5ce8ed2e85e482307",
"grade": false,
"grade_id": "cell-5d906cfc256b7dc5",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"# Q1 SSH, command line, exit codes, etc "
]
},
{
"cell_type": "markdown",
"id": "31eb869a",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "markdown",
"checksum": "66f595465de971d74036d28d9298ee13",
"grade": false,
"grade_id": "cell-8b9d3e971dac9415",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"SSH to your account at `python-course` (e.g. `ssh your-user-name@python-course`) and follow the puzzle starting in the directory `/schnitzeljagd`.\n",
"\n",
"You must be in the University of Freiburg network in order to be able to SSH correctly.\n",
"\n",
"Your username is your the lowercase version of your lastname (e.g. Cem Özdemir would have a username of `oezdemir`). Your password is your matriculation number followed by \"x\" (e.g. `12345678x`).\n",
"\n",
"Place the final answer in the variable `final_answer`."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e7575efb",
"metadata": {
"deletable": false,
"nbgrader": {
"cell_type": "code",
"checksum": "f772ef29b1a729ec4eeaad4e2634a881",
"grade": false,
"grade_id": "cell-d6b141313f4f3a09",
"locked": false,
"schema_version": 3,
"solution": true,
"task": false
}
},
"outputs": [],
"source": [
"# YOUR CODE HERE\n",
"raise NotImplementedError()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a3ef21b2",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "code",
"checksum": "3a43267e90c12761dc250a8853c42d25",
"grade": true,
"grade_id": "cell-3d5b7fe600c4c6ba",
"locked": true,
"points": 1,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"assert ads_hash(final_answer) == 'dfb81c4fac'"
]
},
{
"cell_type": "markdown",
"id": "357ffd1f-d0ce-4992-a0d8-411adadfe332",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "markdown",
"checksum": "5f6549e9a53100f5bb192edf7306c200",
"grade": false,
"grade_id": "cell-3004f9869fd73843",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
},
"tags": []
},
"source": [
"# Q2 Starting conda environment from command line\n",
"\n",
"On the above server, we have Anaconda installed at `/anaconda3` so from the command line, you can start the anaconda `base` environment like this:\n",
"\n",
" eval \"$(/anaconda3/bin/conda shell.bash hook)\"\n",
" \n",
"If you do this, your command-line prompt will start with `(base)`.\n",
" \n",
"Steps:\n",
"\n",
"0) Login to `10.4.66.100` as described above.\n",
"1) Start the anaconda `base` environment.\n",
"2) Change to the directory `/course`.\n",
"3) Run the python program `program1.py`\n",
"4) Put the program console output into the variable `program1_output` below"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8e6b720b-91a6-4ffb-a93b-44e8288c8d86",
"metadata": {
"deletable": false,
"nbgrader": {
"cell_type": "code",
"checksum": "40cd2497dba2639d5241df94737eed1d",
"grade": false,
"grade_id": "cell-6d9ed8460134bae3",
"locked": false,
"schema_version": 3,
"solution": true,
"task": false
},
"tags": []
},
"outputs": [],
"source": [
"# YOUR CODE HERE\n",
"raise NotImplementedError()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4ee8b2c9-8fd0-4d47-86a2-3c52dc352ddd",
"metadata": {
"deletable": false,
"editable": false,
"nbgrader": {
"cell_type": "code",
"checksum": "319c0615f2fed8eed0e03991799d8abe",
"grade": true,
"grade_id": "cell-bc67d9f37b59741d",
"locked": true,
"points": 1,
"schema_version": 3,
"solution": false,
"task": false
},
"tags": []
},
"outputs": [],
"source": [
"assert ads_hash(program1_output) == '983bd614bb'"
]
}
],
"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.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}