diff --git a/python/python.ipynb b/python/python.ipynb index 2a781668..cea524a0 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", @@ -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", @@ -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", "\n"