Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 59 additions & 1 deletion book/content/Exercises/02_python/04_listen/listen.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"tags": [
Expand All @@ -24,27 +25,31 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Listen"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Eine der wichtigsten Datenstrukturen im technischen und wissenschaftlichen Rechnen sind Listen. Später werden auch die damit verwandten Arrays eingeführt, welche diese in vielen numersichen Berechnungen ablösen werden. "
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Grundlagen und Beispiele"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -61,13 +66,15 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Um strukturierte Listen zu erzeugen, kann die `range` Funktion verwendet werden. Diese liefert zwar keine Liste zurück, das Ergebniss kann aber mit dem `list` Befehl in eine Liste umgewandelt werden. "
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -87,6 +94,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -151,13 +159,15 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Aufgabenteil A"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -172,6 +182,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"tags": [
Expand Down Expand Up @@ -328,13 +339,15 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Aufgabenteil B"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -348,6 +361,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"tags": [
Expand Down Expand Up @@ -526,6 +540,50 @@
"liste.sort()\n",
"print(liste)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Aufgabenteil C\n",
"\n",
"Schreiben Sie ein Skript, das eine Liste mit Zahlen von 0 bis 30 ausgibt. Jedoch sollen nur Zahlen nach einem bestimmten Muster in der Liste vorhanden sein. 2 zahlen hinzufügen, danach 3 Zahlen überspringen, danach wieder 2 Zahlen einfügen um darauf die nächsten 3 wieder zu überspringen, usw. bis zur Zahl 30.\n",
"\n",
"Schleifen und Verzweigungen sind erst Teil der nächsten Übungen. Für die Lösung sind nur die Kenntnisse dieser Seite notwendig."
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### Lösungsvorschlag"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": [
"loesung",
"hide-cell"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0, 1, 5, 6, 10, 11, 15, 16, 20, 21, 25, 26]\n"
]
}
],
"source": [
"liste = list(range(0,30,5)) + list(range(1,30,5))\n",
"liste.sort()\n",
"print(liste)"
]
}
],
"metadata": {
Expand All @@ -545,7 +603,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.10.10"
}
},
"nbformat": 4,
Expand Down