From d38d917e716822302315eb40a965757926fc97ee Mon Sep 17 00:00:00 2001
From: Christopher Arndt
Date: Wed, 8 May 2024 17:10:40 +0200
Subject: [PATCH] Updated notebooks
Signed-off-by: Christopher Arndt
---
notebooks/basictypes.html | 333 +-
notebooks/basictypes.ipynb | 284 +-
notebooks/basictypes.py | 47 +-
notebooks/containertypes.html | 150 +-
notebooks/containertypes.ipynb | 131 +-
notebooks/containertypes.py | 29 +-
notebooks/controlflow.html | 357 +-
notebooks/controlflow.ipynb | 295 +-
notebooks/controlflow.py | 2 -
notebooks/data.json | 1 +
notebooks/dateien.html | 7922 +++++++++++++++++++++++++++++++
notebooks/dateien.ipynb | 313 ++
notebooks/dateien.py | 99 +
notebooks/installation.ipynb | 0
notebooks/objects.html | 7923 ++++++++++++++++++++++++++++++++
notebooks/objects.ipynb | 337 ++
notebooks/objects.py | 160 +
17 files changed, 18200 insertions(+), 183 deletions(-)
create mode 100644 notebooks/data.json
create mode 100644 notebooks/dateien.html
create mode 100644 notebooks/dateien.ipynb
create mode 100644 notebooks/dateien.py
delete mode 100644 notebooks/installation.ipynb
create mode 100644 notebooks/objects.html
create mode 100644 notebooks/objects.ipynb
create mode 100644 notebooks/objects.py
diff --git a/notebooks/basictypes.html b/notebooks/basictypes.html
index bf399d8..c0de9bd 100644
--- a/notebooks/basictypes.html
+++ b/notebooks/basictypes.html
@@ -7531,7 +7531,7 @@ a.anchor-link {
-
+
-
-
+
+
+
+
+
+
+
+
3.14159
+<class 'float'>
+2.71828
+8.539721265199999
+<class 'float'>
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
3 1.5 4.5
+<class 'float'>
+<class 'float'>
+0.16666666666666666
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
2
+999
+144
+8.0
+3.8
+1.0
+23.799999999999997
+0.3333333333333333
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
64
+512
+512
+285.0043245227213
+285.0043245227213
+
+
+
+
+
+
+
+
+
+
+
+
+
+
1
+<class 'int'>
+1.2345 1
+0.23449999999999993
+-2
+2.35
+2
+
+
+
+
+
@@ -7675,7 +7796,7 @@ a.anchor-link {
-
+
-
+
+
+
+
+
+
+
+
Dies ist ein String!
+Man kann einfache oder doppelte Anführungszeichen verwenden.
+Innerhalb der Anführungszeichen kann man den jeweils "anderen Typ" verwenden
+Oder 'andersherum'.
+Alternativ kann man eine Backslash 'als' "Escape"-Zeichen verwenden
+String-Literale, die direkt hintereinander, durch Leerzeichen getrennt, stehenwerden zusammengefügt.
+Mit Klammerung klappt das auch über mehrere Zeilen hinweg
+['joe', 'bob', 'alice', 'jenny']
+['joe', 'bob', 'alice', 'jenny']
+['joe', 'bob', 'alice', 'jenny']
+['joe', 'bob', 'alice', 'jenny']
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
Dies ist ein langer String ("triple quoted string").
+Er kann Zeilenumbrüche enthalten.
+
+Und Leerzeilen.
+
+Und auch 'einfache' oder "doppelte" Anführungszeichen.
+
+Er endet mit drei weiteren Anführungszeichen des gleichen Typs.
+
+'Dies ist ein langer String ("triple quoted string").\nEr kann Zeilenumbrüche enthalten.\n\nUnd Leerzeilen.\n\nUnd auch \'einfache\' oder "doppelte" Anführungszeichen.\n\nEr endet mit drei weiteren Anführungszeichen des gleichen Typs.\n'
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
Erste Zeile
+Zweite Zeile
+Eine Zeile
+Noch eine Zeile
+Eins Zwei Drei
+1 2 3
+'Dieser String enthält ein\x00Null-Zeichen'
+Hexadezimal-Codes können wir druckbare (e.g. '@') und nicht druckbare Zeichen (e.g. ) verwendet werden.
+❤
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
Dies ist der erste String.Und dies der zweite.
+Ich habe es dir schon dreimal gesagt! Ich habe es dir schon dreimal gesagt! Ich habe es dir schon dreimal gesagt!
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
SCHREI NICHT SO LAUT!
+True
+True
+True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Hallo
+a
+Hello
+hellohellohello
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+---------------------------------------------------------------------------
+TypeError Traceback (most recent call last)
+/home/chris/work/python-kurs-softed/notebooks/basictypes.ipynb Cell 16 line 3
+ <a href='vscode-notebook-cell:/home/chris/work/python-kurs-softed/notebooks/basictypes.ipynb#X21sZmlsZQ%3D%3D?line=0'>1</a> # Aber das geht nicht!:
+----> <a href='vscode-notebook-cell:/home/chris/work/python-kurs-softed/notebooks/basictypes.ipynb#X21sZmlsZQ%3D%3D?line=2'>3</a> hallo[1] = 'e'
+ <a href='vscode-notebook-cell:/home/chris/work/python-kurs-softed/notebooks/basictypes.ipynb#X21sZmlsZQ%3D%3D?line=4'>5</a> # Strings sind immutable!
+
+TypeError: 'str' object does not support item assignment
+
+
+
+
+
-
+
+
+
+
+
+
+
+
[5, 10, 20, 30, 50]
+[0.5, 0.6, 0.8, 1.0, 1.2]
+['Joe', 'Alice', 'Bob', 'Charly']
+[1, 'Joe', 1.4, 'Alice', 100]
+['one'] [] []
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
(5, 10, 20, 30, 50)
+(0.5, 0.6, 0.8, 1.0, 1.2)
+('Joe', 'Alice', 'Bob', 'Charly')
+(1, 'Joe', 1.4, 'Alice', 100)
+('one',) ('one',) () ()
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
[1, 2, 3, 4, 5] (1, 2, 3, 4, 5)
+[10, 20, 30, 40, 50] (1, 2, 3, 4, 5)
+[1, 2, 3, 4, 5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
['h', 'a', 'l', 'l', 'o']
+('h', 'a', 'l', 'l', 'o')
+
+
+
+
+
@@ -7634,7 +7697,7 @@ a.anchor-link {
-
+
-
+
+
+
+
+
+
+
+
Frühling
+Herbst
+Winter
+Sommer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+---------------------------------------------------------------------------
+IndexError Traceback (most recent call last)
+/home/chris/work/python-kurs-softed/notebooks/containertypes.ipynb Cell 9 line 2
+ <a href='vscode-notebook-cell:/home/chris/work/python-kurs-softed/notebooks/containertypes.ipynb#X11sZmlsZQ%3D%3D?line=0'>1</a> # Ungültige Indizes führen zu einem Fehler (IndexError Exception)
+----> <a href='vscode-notebook-cell:/home/chris/work/python-kurs-softed/notebooks/containertypes.ipynb#X11sZmlsZQ%3D%3D?line=1'>2</a> print(seasons[4]) # 4 Elemente => gültige Indizes 0..3
+
+IndexError: list index out of range
+
+
+
+
+
+
+
@@ -8047,7 +8169,7 @@ a.anchor-link {
In [ ]:
-
# Keys müsen keine Strings, aber immutable sein
+# Keys müssen keine Strings, aber immutable sein
# => Integers, Floats, Tuples sind ok
numbers = {1: "one", 2: "two", 3: "three"}
@@ -8063,10 +8185,8 @@ a.anchor-link {
for row in range(6):
for col in range(10):
- if (row, col) in pixels:
- print(pixels[(row, col)], end="")
- else:
- print(".", end="")
+ value = pixels.get((row, col), ".")
+ print(value, end="")
print()
diff --git a/notebooks/containertypes.ipynb b/notebooks/containertypes.ipynb
index 35161eb..b0757f1 100644
--- a/notebooks/containertypes.ipynb
+++ b/notebooks/containertypes.ipynb
@@ -16,9 +16,21 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[5, 10, 20, 30, 50]\n",
+ "[0.5, 0.6, 0.8, 1.0, 1.2]\n",
+ "['Joe', 'Alice', 'Bob', 'Charly']\n",
+ "[1, 'Joe', 1.4, 'Alice', 100]\n",
+ "['one'] [] []\n"
+ ]
+ }
+ ],
"source": [
"# Listenliterale\n",
"\n",
@@ -38,9 +50,21 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(5, 10, 20, 30, 50)\n",
+ "(0.5, 0.6, 0.8, 1.0, 1.2)\n",
+ "('Joe', 'Alice', 'Bob', 'Charly')\n",
+ "(1, 'Joe', 1.4, 'Alice', 100)\n",
+ "('one',) ('one',) () ()\n"
+ ]
+ }
+ ],
"source": [
"# Tuplelliterale\n",
"values = (5, 10, 20, 30, 50)\n",
@@ -60,9 +84,19 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[1, 2, 3, 4, 5] (1, 2, 3, 4, 5)\n",
+ "[10, 20, 30, 40, 50] (1, 2, 3, 4, 5)\n",
+ "[1, 2, 3, 4, 5]\n"
+ ]
+ }
+ ],
"source": [
"# Umwandlung\n",
"\n",
@@ -77,9 +111,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['h', 'a', 'l', 'l', 'o']\n",
+ "('h', 'a', 'l', 'l', 'o')\n"
+ ]
+ }
+ ],
"source": [
"s = \"hallo\"\n",
"print(list(s))\n",
@@ -95,9 +138,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Frühling\n",
+ "Herbst\n",
+ "Winter\n",
+ "Sommer\n"
+ ]
+ }
+ ],
"source": [
"seasons = [\"Frühling\", \"Sommer\", \"Herbst\", \"Winter\"]\n",
"print(seasons[0]) # Erstes Element hat Index 0!\n",
@@ -108,9 +162,21 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "ename": "IndexError",
+ "evalue": "list index out of range",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
+ "\u001b[1;32m/home/chris/work/python-kurs-softed/notebooks/containertypes.ipynb Cell 9\u001b[0m line \u001b[0;36m2\n\u001b[1;32m
1\u001b[0m \u001b[39m# Ungültige Indizes führen zu einem Fehler (IndexError Exception)\u001b[39;00m\n\u001b[0;32m---->
2\u001b[0m \u001b[39mprint\u001b[39m(seasons[\u001b[39m4\u001b[39;49m]) \u001b[39m# 4 Elemente => gültige Indizes 0..3\u001b[39;00m\n",
+ "\u001b[0;31mIndexError\u001b[0m: list index out of range"
+ ]
+ }
+ ],
"source": [
"# Ungültige Indizes führen zu einem Fehler (IndexError Exception)\n",
"print(seasons[4]) # 4 Elemente => gültige Indizes 0..3"
@@ -179,6 +245,7 @@
"outputs": [],
"source": [
"l = list(range(10)) # l = [0, 1, ..., 9]\n",
+ "print(l)\n",
"print(l[2:4]) # Start ist inklusiv, Ende nicht!"
]
},
@@ -214,11 +281,13 @@
"source": [
"# Sind Start und Ende leer, ist das Ergebnis eine Kopie der Liste / des Tuples\n",
"\n",
- "l = [1, 2, 3]\n",
- "l2 = l[:]\n",
- "l[0] = 999\n",
- "print(l)\n",
- "print(l2)"
+ "l1 = [1, 2, 3]\n",
+ "l2 = l1[:]\n",
+ "l3 = l1\n",
+ "l1[0] = 999\n",
+ "print(l1)\n",
+ "print(l2)\n",
+ "print(l3)"
]
},
{
@@ -280,7 +349,22 @@
"t += (1, 2, 3) # Tuples sind immutable, t ist eine neue Kopie!\n",
"print(t)\n",
"print(t2)\n",
- "print(t is t2)\n"
+ "print(t is t2)\n",
+ "s = \"ein string\"\n",
+ "s += \" und noch mehr\"\n",
+ "i = 0\n",
+ "i += 1\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "l = list(range(10))\n",
+ "import sys\n",
+ "sys.getsizeof(l)"
]
},
{
@@ -341,7 +425,8 @@
"\n",
"scores[\"white team\"] = 45\n",
"scores[\"rainbow team\"] = 50\n",
- "print(scores)"
+ "print(scores)\n",
+ "del scores[\"blue team\"]"
]
},
{
@@ -391,7 +476,7 @@
"metadata": {},
"outputs": [],
"source": [
- "# Keys müsen keine Strings, aber immutable sein\n",
+ "# Keys müssen keine Strings, aber immutable sein\n",
"# => Integers, Floats, Tuples sind ok\n",
"\n",
"numbers = {1: \"one\", 2: \"two\", 3: \"three\"}\n",
@@ -407,10 +492,8 @@
"\n",
"for row in range(6):\n",
" for col in range(10):\n",
- " if (row, col) in pixels:\n",
- " print(pixels[(row, col)], end=\"\")\n",
- " else:\n",
- " print(\".\", end=\"\")\n",
+ " value = pixels.get((row, col), \".\")\n",
+ " print(value, end=\"\")\n",
" print()\n"
]
},
diff --git a/notebooks/containertypes.py b/notebooks/containertypes.py
index 75fb3a6..18e8753 100644
--- a/notebooks/containertypes.py
+++ b/notebooks/containertypes.py
@@ -97,6 +97,7 @@ t[2] = "drei"
# %%
l = list(range(10)) # l = [0, 1, ..., 9]
+print(l)
print(l[2:4]) # Start ist inklusiv, Ende nicht!
# %%
@@ -114,11 +115,13 @@ print(l[:3]) # auch hier ist der Ende-Index nicht-inklusiv!
# %%
# Sind Start und Ende leer, ist das Ergebnis eine Kopie der Liste / des Tuples
-l = [1, 2, 3]
-l2 = l[:]
-l[0] = 999
-print(l)
+l1 = [1, 2, 3]
+l2 = l1[:]
+l3 = l1
+l1[0] = 999
+print(l1)
print(l2)
+print(l3)
# %%
# Zuweisung an Listenslices ist möglich!
@@ -158,8 +161,17 @@ t += (1, 2, 3) # Tuples sind immutable, t ist eine neue Kopie!
print(t)
print(t2)
print(t is t2)
+s = "ein string"
+s += " und noch mehr"
+i = 0
+i += 1
+# %%
+l = list(range(10))
+import sys
+sys.getsizeof(l)
+
# %% [markdown]
# ## Dictionaries
@@ -192,6 +204,7 @@ print("The red team scored:", scores["red team"])
scores["white team"] = 45
scores["rainbow team"] = 50
print(scores)
+del scores["blue team"]
# %%
# Umwandlung
@@ -217,7 +230,7 @@ for key, value in scores.items():
print("Das", key, "hat", value, "Punkte.")
# %%
-# Keys müsen keine Strings, aber immutable sein
+# Keys müssen keine Strings, aber immutable sein
# => Integers, Floats, Tuples sind ok
numbers = {1: "one", 2: "two", 3: "three"}
@@ -233,10 +246,8 @@ pixels = {
for row in range(6):
for col in range(10):
- if (row, col) in pixels:
- print(pixels[(row, col)], end="")
- else:
- print(".", end="")
+ value = pixels.get((row, col), ".")
+ print(value, end="")
print()
diff --git a/notebooks/controlflow.html b/notebooks/controlflow.html
index 0f17ba4..ad2f846 100644
--- a/notebooks/controlflow.html
+++ b/notebooks/controlflow.html
@@ -7531,7 +7531,7 @@ a.anchor-link {
-
+
-
+
+
+
+
+
+
+
+
Hmm, ob das so stimmt?
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
Nach Süden, nach Süden!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Auf in den hohen Norden!
+
+
+
+
+
@@ -7617,7 +7656,7 @@ a.anchor-link {
-
+
-
+
+
+
+
+
+
+
+
Schleifendurchlauf Nr. 0
+Schleifendurchlauf Nr. 1
+Schleifendurchlauf Nr. 2
+Schleifendurchlauf Nr. 3
+Schleifendurchlauf Nr. 4
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
Summe der Zahlen 1-10: 55
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
9 passt nicht in die Reihe
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
10 ... 9 ... 8 ... 7 ... 6 ... 5 ... 4 ... 3 ... 2 ... 1 ... Lift off!
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
10
+11
+12
+14
+15
+16
+17
+18
+19
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
q ist Buchstabe Nr. 17 des dt. Alphabets.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
q ist Buchstabe Nr. 17 des dt. Alphabets.
+
+
+
+
+
@@ -7784,7 +7939,7 @@ a.anchor-link {
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+ Cell In[32], line 2
+ print(add(a=6, 10))
+ ^
+SyntaxError: positional argument follows keyword argument
+
+
+
+
+
@@ -7882,7 +8108,7 @@ a.anchor-link {
-
+
-
+
+
+
+
+
+
+
+
False
+True
+False
+True
+True
+False
+True
+True
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
True
+True
+True
+False
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
True
+True
+True
+False
+
+
+
+
+
+
+
+
+
+
+
+
+
+
False
+True
+True
+False
+True
+True
+True
+True
+False
+True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<class 'bytes'>
+<class 'str'>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Anna: 2000
+Mark: 3000
+Judith: 3500
+Thomas: 2500
+Barbara: 3000
+Elke: 3300
+Michael: 2800
+Johann: 2000
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<class 'list'>
+['Anna: 2000\n', 'Mark: 3000\n', 'Judith: 3500\n', 'Thomas: 2500\n', 'Barbara: 3000\n', 'Elke: 3300\n', 'Michael: 2800\n', 'Johann: 2000\n']
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Anna: 2000
+Mark: 3000
+Judith: 3500
+Thomas: 2500
+Barbara: 3000
+Elke: 3300
+Michael: 2800
+Johann: 2000
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Anna: 2000
+Mark: 3000
+Judith: 3500
+Thomas: 2500
+Barbara: 3000
+Elke: 3300
+Michael: 2800
+Johann: 2000
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Anna: 2000
+Mark: 3000
+Judith: 3500
+Thomas: 2500
+Barbara: 3000
+Elke: 3300
+Michael: 2800
+Johann: 2000
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
[1, 2, 3]
+{"foo": 42, "bar": 23}
+{"foo": 42, "bar": 23, "baz": [1, 2, 3]}
+[{"foo": 42, "bar": 23}, {"foo": 42, "bar": 23, "baz": [1, 2, 3]}]
+
+
+
+
+
+
+
+
diff --git a/notebooks/controlflow.ipynb b/notebooks/controlflow.ipynb
index 25f8eee..1db9637 100644
--- a/notebooks/controlflow.ipynb
+++ b/notebooks/controlflow.ipynb
@@ -16,9 +16,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hmm, ob das so stimmt?\n"
+ ]
+ }
+ ],
"source": [
"# if / else / elif\n",
"\n",
@@ -34,9 +42,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 18,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Nach Süden, nach Süden!\n"
+ ]
+ }
+ ],
"source": [
"richtung = \"s\"\n",
"\n",
@@ -52,9 +68,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 19,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Auf in den hohen Norden!\n"
+ ]
+ }
+ ],
"source": [
"# match\n",
"\n",
@@ -83,9 +107,21 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 20,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Schleifendurchlauf Nr. 0\n",
+ "Schleifendurchlauf Nr. 1\n",
+ "Schleifendurchlauf Nr. 2\n",
+ "Schleifendurchlauf Nr. 3\n",
+ "Schleifendurchlauf Nr. 4\n"
+ ]
+ }
+ ],
"source": [
"# for\n",
"\n",
@@ -95,9 +131,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 21,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Summe der Zahlen 1-10: 55\n"
+ ]
+ }
+ ],
"source": [
"result = 0\n",
"for i in range(1, 11):\n",
@@ -107,9 +151,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 22,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "9 passt nicht in die Reihe\n"
+ ]
+ }
+ ],
"source": [
"for i in (2, 4, 6, 8, 9, 10):\n",
" if i % 2:\n",
@@ -118,9 +170,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 23,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "10 ... 9 ... 8 ... 7 ... 6 ... 5 ... 4 ... 3 ... 2 ... 1 ... Lift off!\n"
+ ]
+ }
+ ],
"source": [
"# while\n",
"\n",
@@ -133,9 +193,25 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 24,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "10\n",
+ "11\n",
+ "12\n",
+ "14\n",
+ "15\n",
+ "16\n",
+ "17\n",
+ "18\n",
+ "19\n"
+ ]
+ }
+ ],
"source": [
"# continue\n",
"\n",
@@ -147,9 +223,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 25,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Iteration: 142\n"
+ ]
+ }
+ ],
"source": [
"# break\n",
"\n",
@@ -169,9 +253,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 26,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "q ist Buchstabe Nr. 17 des dt. Alphabets.\n"
+ ]
+ }
+ ],
"source": [
"alphabet = \"abcdefghifklmnopqrstuvwxyz\"\n",
"buchstabe = \"q\"\n",
@@ -185,9 +277,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 27,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "q ist Buchstabe Nr. 17 des dt. Alphabets.\n"
+ ]
+ }
+ ],
"source": [
"# einfacher:\n",
"\n",
@@ -206,9 +306,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 28,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "256 256 100\n"
+ ]
+ }
+ ],
"source": [
"# Aufruf eingebauter Funktionen\n",
"\n",
@@ -220,9 +328,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 29,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "\n"
+ ]
+ }
+ ],
"source": [
"# optionale Parameter\n",
"\n",
@@ -232,9 +349,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 30,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "5\n"
+ ]
+ }
+ ],
"source": [
"# eigene Funktionen\n",
"\n",
@@ -246,9 +371,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 31,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "15\n",
+ "24\n"
+ ]
+ }
+ ],
"source": [
"# Keyword arguments\n",
"\n",
@@ -258,9 +392,18 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 32,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "ename": "SyntaxError",
+ "evalue": "positional argument follows keyword argument (1525390589.py, line 2)",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;36m Cell \u001b[0;32mIn[32], line 2\u001b[0;36m\u001b[0m\n\u001b[0;31m print(add(a=6, 10))\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m positional argument follows keyword argument\n"
+ ]
+ }
+ ],
"source": [
"# Das geht nicht:\n",
"print(add(a=6, 10))"
@@ -275,9 +418,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 35,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "False\n",
+ "True\n",
+ "False\n",
+ "True\n",
+ "True\n",
+ "False\n",
+ "True\n",
+ "True\n"
+ ]
+ }
+ ],
"source": [
"a = 10\n",
"b = 50\n",
@@ -296,9 +454,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 36,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "True\n",
+ "True\n",
+ "True\n",
+ "False\n"
+ ]
+ }
+ ],
"source": [
"# Negation\n",
"\n",
@@ -310,9 +479,19 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 37,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "True\n",
+ "True\n",
+ "True\n"
+ ]
+ }
+ ],
"source": [
"# logische Kombination\n",
"\n",
@@ -323,23 +502,51 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 38,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "True\n",
+ "True\n",
+ "True\n",
+ "False\n"
+ ]
+ }
+ ],
"source": [
"# Bool'scher (True/False) Wert von Integers, Floats und Strings \n",
"print(a > c)\n",
"print(bool(a > c)) ## redundant, da Vergleichsausdrücke immer einen bool'schen Wert haben\n",
"# Aber:\n",
"print(bool(a))\n",
- "print(not a) # auch ein bool'scher Ausdruck\n"
+ "print(not a) # auch ein bool'scher Ausdruck"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 33,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "False\n",
+ "True\n",
+ "True\n",
+ "False\n",
+ "True\n",
+ "True\n",
+ "True\n",
+ "True\n",
+ "False\n",
+ "True\n"
+ ]
+ }
+ ],
"source": [
"print(bool(0))\n",
"print(bool(1))\n",
@@ -350,7 +557,7 @@
"print(bool(\"True\"))\n",
"print(bool(\"False\")) # !!!\n",
"print(bool(\"\"))\n",
- "print(bool(\"\\0\"))\n"
+ "print(bool(\"\\0\"))"
]
}
],
diff --git a/notebooks/controlflow.py b/notebooks/controlflow.py
index c8b442c..61a10eb 100644
--- a/notebooks/controlflow.py
+++ b/notebooks/controlflow.py
@@ -197,7 +197,6 @@ print(bool(a > c)) ## redundant, da Vergleichsausdrücke immer einen bool'schen
print(bool(a))
print(not a) # auch ein bool'scher Ausdruck
-
# %%
print(bool(0))
print(bool(1))
@@ -211,4 +210,3 @@ print(bool(""))
print(bool("\0"))
-
diff --git a/notebooks/data.json b/notebooks/data.json
new file mode 100644
index 0000000..bfdb802
--- /dev/null
+++ b/notebooks/data.json
@@ -0,0 +1 @@
+{"foo": 42, "bar": 23, "baz": [1, 2, 3]}
\ No newline at end of file
diff --git a/notebooks/dateien.html b/notebooks/dateien.html
new file mode 100644
index 0000000..e5ceb5a
--- /dev/null
+++ b/notebooks/dateien.html
@@ -0,0 +1,7922 @@
+
+
+
+