Skip to content

Commit

Permalink
Merge pull request #416 from pep-dortmund/fixes-to-python-notebook
Browse files Browse the repository at this point in the history
Fixes to python notebook
  • Loading branch information
LuckyJosh authored Sep 23, 2024
2 parents 6ee25a1 + 91315af commit 7a50f3b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions python/python.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"\n",
"- Aktuelle Version: Python 3.12\n",
"- *Interpretierte* Programmiersprache\n",
" - Kein Kompilieren\n",
" - In der Standardversion `cpython`: kein Kompilieren zu Maschinencode, [sondern zu Bytecode](https://github.com/python/cpython/blob/main/InternalDocs/compiler.md)\n",
" - Programme werden mit dem `python`-Programm ausgeführt\n",
"- Eignet sich sehr gut zum Erlernen der Programmierung!\n",
"- Viele nützliche Pakete, die das wissenschaftliche Arbeiten extrem erleichtern!\n",
Expand Down Expand Up @@ -2219,9 +2219,10 @@
"T = [0.25, 0.5, 0.75, 1.0, 1.25, 1.5]\n",
"\n",
"# ohne Schleife\n",
"data = {\"t\":T, \"h\": [h(T[0]),h(T[1]),h(T[2]),h(T[3]),h(T[4]),h(T[5])],\n",
" \"v\": [v(T[0]),v(T[1]),v(T[2]),v(T[3]),v(T[4]),v(T[5])],\n",
" \"a\": [a(T[0]),a(T[1]),a(T[2]),a(T[3]),a(T[4]),a(T[5])]}\n",
"data = {\"t\":T,\n",
" \"h\": [h(T[0]), h(T[1]), h(T[2]), h(T[3]), h(T[4]), h(T[5])],\n",
" \"v\": [v(T[0]), v(T[1]), v(T[2]), v(T[3]), v(T[4]), v(T[5])],\n",
" \"a\": [a(T[0]), a(T[1]), a(T[2]), a(T[3]), a(T[4]), a(T[5])]}\n",
"\n",
"print(data)\n",
"\n",
Expand Down Expand Up @@ -2255,6 +2256,12 @@
"\n",
"for k,v in data.items():\n",
" print(f\"{k} {v[0]:6.2f} {v[1]:6.2f} {v[2]:6.2f} {v[3]:6.2f} {v[4]:6.2f} {v[5]:6.2f}\")\n",
"\n",
"# Noch eine Schleife (List-Comprehension) mehr, erübrigt die Wiederholungen\n",
"\n",
"for key, values in data.items():\n",
" formatted_values = \" \".join([f\"{v:6.2f}\" for v in values])\n",
" print(f\"{key} {formatted_values}\")\n",
"```\n",
"\n",
"</details>\n"
Expand Down

0 comments on commit 7a50f3b

Please sign in to comment.