Skip to content

Commit

Permalink
moved the solutions to the end, the detail tags are expanded in the h…
Browse files Browse the repository at this point in the history
…tml export
  • Loading branch information
LuckyJosh committed Sep 22, 2024
1 parent e3e7920 commit 03da57d
Showing 1 changed file with 172 additions and 121 deletions.
293 changes: 172 additions & 121 deletions python/python.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -387,26 +387,7 @@
"3. Prüfe, ob des Objekt bereits über einen Meter gefallen ist.\n",
"\n",
"\n",
"\n",
"<details>\n",
"<summary>Lösung</summary>\n",
" \n",
"```\n",
"# 1.\n",
"t = 0.5\n",
"h_i = 10\n",
"v_i = 0.75\n",
"a_i = -9.81\n",
"\n",
"# 2.\n",
"h = h_i + v_i * t + 1/2 * a_i * t**2 \n",
"v = v_i * t + a_i * t \n",
"a = a_i\n",
"\n",
"# 3.\n",
"h < 9\n",
"```\n",
"</details>\n"
"Die Lösungen für die Kurzaufgaben sind am Ende dieser Datei."
]
},
{
Expand Down Expand Up @@ -552,32 +533,7 @@
"source": [
"### Kurzaufgaben 4\n",
"4. Nutze die `print`-Funktion, um die gegebenen Startwerte \n",
"und die Ergebnisse der letzten Kurzaufgabe mit Überschritfen zu versehen und auszugeben.\n",
"\n",
"<details>\n",
"<summary>Lösung</summary>\n",
" \n",
"```\n",
"# 4.\n",
"print(\"Start...\")\n",
"print(\"...höhe\")\n",
"print(h_i)\n",
"print(\"...geschwindigkeit\")\n",
"print(v_i)\n",
"print(\"...beschleunigung\")\n",
"print(a_i)\n",
"\n",
"print(\"Nach der Zeit t\")\n",
"print(t)\n",
"print(\"Höhe\")\n",
"print(h)\n",
"print(\"Geschwindigkeit\")\n",
"print(v)\n",
"print(\"Beschleunigung\")\n",
"print(a)\n",
"\n",
"```\n",
"</details>\n"
"und die Ergebnisse der letzten Kurzaufgabe mit Überschritfen zu versehen und auszugeben."
]
},
{
Expand Down Expand Up @@ -850,37 +806,7 @@
" b) die Ergebnisse an die zugehörige Liste anhängst\n",
" \n",
" \n",
" Gibt die Listen H, V, A mit der `print`-Funktion aus\n",
"\n",
"\n",
"<details>\n",
"<summary>Lösung</summary>\n",
" \n",
"```\n",
"# 5.\n",
"T = [0.5, 1, 1.5]\n",
"H = []\n",
"V = []\n",
"A = []\n",
"\n",
"\n",
"H.append(h_i + v_i * T[0] + 1/2 * a_i * T[0]**2)\n",
"H.append(h_i + v_i * T[1] + 1/2 * a_i * T[1]**2)\n",
"H.append(h_i + v_i * T[2] + 1/2 * a_i * T[2]**2)\n",
"\n",
"V.append(v_i * T[0] + a_i * T[0])\n",
"V.append(v_i * T[1] + a_i * T[1])\n",
"V.append(v_i * T[2] + a_i * T[2])\n",
"\n",
"A.append(a_i)\n",
"A.append(a_i)\n",
"A.append(a_i)\n",
"\n",
"print(H)\n",
"print(V)\n",
"print(A)\n",
"```\n",
"</details>\n"
" Gibt die Listen H, V, A mit der `print`-Funktion aus\n"
]
},
{
Expand Down Expand Up @@ -986,25 +912,7 @@
"7. Greife auf die folgenden Werte im Dictionary zu:\n",
"- der zweite Wert von t\n",
"- der erste Wert von v\n",
"- der letzte Wert von h\n",
"\n",
"\n",
"<details>\n",
"<summary>Lösung</summary>\n",
" \n",
"```\n",
"# 6.\n",
"data = {\"t\":T, \"h\": H, \"v\": V, \"a\":A}\n",
"print(data)\n",
"\n",
"\n",
"# 7.\n",
"print(data[\"t\"][1])\n",
"print(data[\"v\"][0])\n",
"print(data[\"h\"][-1])\n",
"\n",
"```\n",
"</details>"
"- der letzte Wert von h\n"
]
},
{
Expand Down Expand Up @@ -1438,15 +1346,7 @@
"Schleife verwenden.\n",
"\n",
"Gib data mit der `print`-Funktion aus.\n",
"\n",
"\n",
"<details>\n",
"<summary>Lösung</summary>\n",
" \n",
"```\n",
"\n",
"```\n",
"</details>"
"\n"
]
},
{
Expand Down Expand Up @@ -1715,22 +1615,6 @@
"a -9.81 -9.81 -9.81 -9.81 -9.81 -9.81\n",
"```\n",
"Jede Zeile der Tabelle kann dabei durch Verwendung eines f-Strings formatiert werden.\n",
"\n",
"<details>\n",
"<summary>Lösung</summary>\n",
" \n",
"```\n",
"for k,v in data.items():\n",
" print(f\"{k} {v[0]:.2f} {v[1]:.2f} {v[2]:.2f} {v[3]:.2f} {v[4]:.2f} {v[5]:.2f}\")\n",
"\n",
"# Am Dezimaltrennzeichen ausgerichtet\n",
"\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",
"\n",
"</details>\n",
"\n",
"\n"
]
},
Expand Down Expand Up @@ -2208,6 +2092,173 @@
"die vorher definiert wurden. Man kann dann interaktiv nach Problemen im Code suchen\n",
"oder wie hier herausfinden wie Code funktioniert."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Lösungen für die Kurzaufgaben\n",
"\n",
"<details>\n",
"<summary>Lösung zu 1., 2. und 3.</summary>\n",
" \n",
"```\n",
"# 1.\n",
"t = 0.5\n",
"h_i = 10\n",
"v_i = 0.75\n",
"a_i = -9.81\n",
"\n",
"# 2.\n",
"h = h_i + v_i * t + 1/2 * a_i * t**2 \n",
"v = v_i * t + a_i * t \n",
"a = a_i\n",
"\n",
"# 3.\n",
"h < 9\n",
"```\n",
"</details>\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"<details>\n",
"<summary>Lösung zu 4.</summary>\n",
" \n",
"```\n",
"# 4.\n",
"print(\"Start...\")\n",
"print(\"...höhe\")\n",
"print(h_i)\n",
"print(\"...geschwindigkeit\")\n",
"print(v_i)\n",
"print(\"...beschleunigung\")\n",
"print(a_i)\n",
"\n",
"print(\"Nach der Zeit t\")\n",
"print(t)\n",
"print(\"Höhe\")\n",
"print(h)\n",
"print(\"Geschwindigkeit\")\n",
"print(v)\n",
"print(\"Beschleunigung\")\n",
"print(a)\n",
"\n",
"```\n",
"</details>\n",
"\n",
"\n",
"<details>\n",
"<summary>Lösung zu 5.</summary>\n",
" \n",
"```\n",
"# 5.\n",
"T = [0.5, 1, 1.5]\n",
"H = []\n",
"V = []\n",
"A = []\n",
"\n",
"\n",
"H.append(h_i + v_i * T[0] + 1/2 * a_i * T[0]**2)\n",
"H.append(h_i + v_i * T[1] + 1/2 * a_i * T[1]**2)\n",
"H.append(h_i + v_i * T[2] + 1/2 * a_i * T[2]**2)\n",
"\n",
"V.append(v_i * T[0] + a_i * T[0])\n",
"V.append(v_i * T[1] + a_i * T[1])\n",
"V.append(v_i * T[2] + a_i * T[2])\n",
"\n",
"A.append(a_i)\n",
"A.append(a_i)\n",
"A.append(a_i)\n",
"\n",
"print(H)\n",
"print(V)\n",
"print(A)\n",
"```\n",
"</details>\n",
"\n",
"\n",
"<details>\n",
"<summary>Lösung zu 6. und 7.</summary>\n",
" \n",
"```\n",
"# 6.\n",
"data = {\"t\":T, \"h\": H, \"v\": V, \"a\":A}\n",
"print(data)\n",
"\n",
"\n",
"# 7.\n",
"print(data[\"t\"][1])\n",
"print(data[\"v\"][0])\n",
"print(data[\"h\"][-1])\n",
"\n",
"```\n",
"</details>\n",
"\n",
"\n",
"<details>\n",
"<summary>Lösung zu 8. und 9.</summary>\n",
" \n",
"```\n",
"# 8.\n",
"def h(t):\n",
" return h_i + v_i * t + 1/2 * a_i * t**2\n",
"\n",
"\n",
"def v(t):\n",
" return v_i * t + a_i * t\n",
"\n",
"\n",
"def a(t):\n",
" return a_i\n",
"\n",
"\n",
"# 9.\n",
"\n",
"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",
"\n",
"print(data)\n",
"\n",
"\n",
"# mit Schleife\n",
"H = []\n",
"V = []\n",
"A = []\n",
"\n",
"for t in T:\n",
" H.append(h(t))\n",
" V.append(v(t))\n",
" A.append(a(t))\n",
"\n",
"\n",
"data = {\"t\":T, \"h\": H, \"v\": V, \"a\": A}\n",
"print(data)\n",
"\n",
"```\n",
"</details>\n",
"\n",
"\n",
"<details>\n",
"<summary>Lösung zu 10.</summary>\n",
" \n",
"```\n",
"for k,v in data.items():\n",
" print(f\"{k} {v[0]:.2f} {v[1]:.2f} {v[2]:.2f} {v[3]:.2f} {v[4]:.2f} {v[5]:.2f}\")\n",
"\n",
"# Am Dezimaltrennzeichen ausgerichtet\n",
"\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",
"\n",
"</details>\n"
]
}
],
"metadata": {
Expand Down

0 comments on commit 03da57d

Please sign in to comment.