From 3238c74d66e3917607d26bfe81117286afa2020e Mon Sep 17 00:00:00 2001 From: Joshua Luckey Date: Mon, 23 Sep 2024 09:53:09 +0200 Subject: [PATCH 1/3] fixed fake news about python not being compiled --- python/python.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/python.ipynb b/python/python.ipynb index 2a781668..23bdab38 100644 --- a/python/python.ipynb +++ b/python/python.ipynb @@ -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", From d37fcc60dd0972d247971da0f56766f55706191c Mon Sep 17 00:00:00 2001 From: Joshua Luckey Date: Mon, 23 Sep 2024 09:53:27 +0200 Subject: [PATCH 2/3] fix code formatting in solution of short tasks --- python/python.ipynb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/python.ipynb b/python/python.ipynb index 23bdab38..57514e2c 100644 --- a/python/python.ipynb +++ b/python/python.ipynb @@ -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", From 91315affdbebfdd50441a93d4c3d7253999700ae Mon Sep 17 00:00:00 2001 From: Joshua Luckey Date: Mon, 23 Sep 2024 09:53:55 +0200 Subject: [PATCH 3/3] add one last solution using a comprehension --- python/python.ipynb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/python.ipynb b/python/python.ipynb index 57514e2c..cea524a0 100644 --- a/python/python.ipynb +++ b/python/python.ipynb @@ -2256,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", "\n"