diff --git a/01_Jupyter.ipynb b/01_Jupyter.ipynb new file mode 100644 index 0000000..130dd89 --- /dev/null +++ b/01_Jupyter.ipynb @@ -0,0 +1,99 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "id": "7dc85437-cea7-444b-befa-5762492c9a5d", + "metadata": {}, + "source": [ + "# Einführung\n", + "\n", + "Dieses Tutrial soll einen kurzen Einblick in Python geben und die für das Seminar notwendigen Kenntnisse vermitteln.\n", + "\n", + "Sollten sie Anregungen oder Wünsche habe können sie diese gerne Mitteilen. \n", + "Schreiben sie eine Email an [david-peter.federl@uni-due.de](mailto:david-peter.federl@uni-due.de) oder sprechen sie uns nach dem Seminar an. \n", + "Wir sind stets bemüht auf ihre Anregungen einzugehen.\n", + "\n", + "Wir verwenden für das Hosting dieses Tutorials [Binder](https://jupyter.org/binder) um ihnen eine möglichst interaktive Einführung in Python zu bieten." + ] + }, + { + "cell_type": "markdown", + "id": "a86d00fc-27a7-432e-96f7-5dc438ad583c", + "metadata": {}, + "source": [ + "## Jupyter Basics\n", + "\n", + "Jupyter Notebooks bieten eine gute Möglichkeit Python in einer isolierten Umgebung auszuführen und mit Markdown basierter Dokumentation zu kombinieren.\n", + "\n", + "Es besteht aus Zellen die entweder Python Source Code oder Markdown Text enthalten." + ] + }, + { + "cell_type": "markdown", + "id": "2bb304ee-3add-4eb9-9e78-433de34379b1", + "metadata": {}, + "source": [ + "Diese Zelle enthält Markdown. Sie kann Text in der Markdown Syntax enthalten.\n", + "\n", + "- **Fett**\n", + "- _Kursiv_\n", + "- ...\n", + "\n", + "Der Text wird gerendert, wenn die Zelle durch das pressen von CTRL+Enter ausgeführt wird." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "e3a346df-6843-4569-88c2-9abe6cab436e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello there!\n" + ] + } + ], + "source": [ + "# Diese Zelle enthält Python Source-Code\n", + "# Sie durch das pressen von CTRL+Enter ausgeführt werden.\n", + "\n", + "print(\"Hello there!\")" + ] + }, + { + "cell_type": "markdown", + "id": "d55cccf5-014f-4f3b-bc9d-4a4e093d5955", + "metadata": {}, + "source": [ + "---\n", + "\n", + "**[WEITER (Python)](./02_Python_Basics.ipynb)**" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "test-binder", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/02_Python_Basics.ipynb b/02_Python_Basics.ipynb new file mode 100644 index 0000000..dd9919b --- /dev/null +++ b/02_Python_Basics.ipynb @@ -0,0 +1,829 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "15a90de5-8d0d-4026-950e-1dc8262b38e6", + "metadata": {}, + "source": [ + "# Python Tutorial" + ] + }, + { + "cell_type": "markdown", + "id": "1bf637e9-287b-4c7c-b723-671d0604a42d", + "metadata": {}, + "source": [ + "## Grundlagen" + ] + }, + { + "cell_type": "markdown", + "id": "bfd92443", + "metadata": {}, + "source": [ + "Python ist für seine Benutzerfreundlichkeit bekannt.\n", + "Diese kann für erfahrene Programmierer jedoch auch von Nachteil sein.\n", + "\n", + "Durch ein fehlendes Typensystem und die flexiblen Implementierungsmöglichkeiten, so wie der Tatsache das es sich um eine Interpreter basierte Sprache handelt, kann man viele Konzepte die Programmierern geläufig sind ignorieren und der Code ist dennoch ausführbar.\n", + "Wir werden in diesem Tutorial darauf verzichten auf diese Schwachstellen aufmerksam zu machen und bewusst eine korrekte Anwendung der Sprache demonstrieren.\n", + "\n", + "Im Nachfolgenden werden einige grundlegende Programmierkonzepte erläutert um den Umgang mit Python zu festigen." + ] + }, + { + "cell_type": "markdown", + "id": "db343fb3-0dad-4e6c-927e-895a82d6f6a2", + "metadata": {}, + "source": [ + "### Variablen" + ] + }, + { + "cell_type": "markdown", + "id": "0f85abb4", + "metadata": {}, + "source": [ + "Variablen haben in Python keine feste Typenzuweisung.\n", + "Sie werden dynamisch bei der Zuweisung von Werten festgelegt.\n", + "\n", + "Sollte einer Variablen ein Wert von einem anderen Typ zugewiesen werden ist dies ohne Probleme möglich, da der Interpreter dies nicht kontrolliert.\n", + "Um eine gewisse Typsicherheit zu gewährleisten werden daher häufig spezielle Linter wie [mypy](https://www.mypy-lang.org) genutzt, welche den Typ einer Variable mit den zugewiesenen Werten vergleichen. \n", + "Damit Typechecker wie mypy wissen welchen Typ eine Variable haben sollte kann man sogenannte _type hints_ an den Namen einer Variable schreiben.\n", + "\n", + "```python\n", + "var_name: type-hint = value\n", + "```\n", + "\n", + "Für das anlegen einer Variable ist das Zuweisen eines Wertes optional!" + ] + }, + { + "cell_type": "markdown", + "id": "dd2322be", + "metadata": {}, + "source": [ + "**Einfache _type hints_:**\n", + "\n", + "| Typ | Erklärung |\n", + "| ----: | :----------------------------------------------------- |\n", + "| None | Spezielle Wert, der angibt das es keinen Wert gibt. |\n", + "| int | Ganzzahlige Werte (Integer, Long, ...) |\n", + "| float | Fließkommazahlen (Float, Double, ...) |\n", + "| bool | Wahrheitswerte (Boolean: True, False) |\n", + "| str | Zeichenketten (Character, String, ...) |\n", + "| bytes | Bytefolge (ASCII wird automatisch in Byte konvertiert) |\n", + "\n", + "**Komplexe _type hints_:**\n", + "| Typ | Erklärung |\n", + "| ----: | :- |\n", + "| dict | Dictionary. Der Typ von Schlüssel und Wert kann in eckigen Klammern angegeben werden: `dict[str,int]` -> Schlüssel: str, Werte: int |\n", + "| list | Ungeordnete Liste. Der Typ der Elemente kann in Eckigen Klammern angegeben werden: `list[int,float]` -> Liste mit int und float Werten |\n", + "| set | Geordnete Liste mit variabler Länge. Der Typ der Elemente kann in Eckigen Klammern angegeben werden: `set[int,float]` -> Set mit int und float Werten |\n", + "| tuple | Geordnete Liste mit fester Länge. Der Typ der Elemente kann in Eckigen Klammern angegeben werden: `set[int, ...]` -> Set mit int Werten, `set[float, str]` -> Set mit float und str Werte |\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "013b05ba-858c-41f2-9dbf-cc2266db803d", + "metadata": {}, + "outputs": [], + "source": [ + "# Legen sie eine Variable mit dem Namen 'name' vom Typ String an und weisen ihr als Werte ihren Namen zu.\n", + "\n", + "name: ..." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "95a277f6", + "metadata": {}, + "outputs": [], + "source": [ + "# Legen sie ein Tupel mit 3 Integer Werten an und weisen sie ihm als Wert ihren Geburtstag (dd,mm,yyyy) zu.\n", + "\n", + "birthday: ..." + ] + }, + { + "cell_type": "markdown", + "id": "cf631205", + "metadata": {}, + "source": [ + "### Ausgabe in das Terminal" + ] + }, + { + "cell_type": "markdown", + "id": "06be4122", + "metadata": {}, + "source": [ + "Eine Ausgabe in das Terminal kann am einfachsten mit der Methode \n", + "\n", + "```python\n", + "print(\"...\")\n", + "```\n", + "\n", + "abgesetzt werden.\n", + "\n", + "Sie können Variablen in ihre Ausgabe einbeziehen indem sie f-Strings nutzen:\n", + "\n", + "```python\n", + "f\"text {var_name} ...\"\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e4cf13da", + "metadata": {}, + "outputs": [], + "source": [ + "# versuchen sie ihren Namen aus der Variable _name_ auszugeben:\n", + "\n", + "..." + ] + }, + { + "cell_type": "markdown", + "id": "93bef8a9-50fe-48fe-a040-1e7261fb18f0", + "metadata": {}, + "source": [ + "### Einrückung: Methoden und Klassen" + ] + }, + { + "cell_type": "markdown", + "id": "d133fa02", + "metadata": {}, + "source": [ + "Einrückung ersetzt in Python geschweifte Klammern `{}` oder andere Gruppierungsmerkmale für Statements\n", + "\n", + "Es ist daher sehr wichtig stets auf eine konsistente Einrückung zu achten.\n", + "Standardmäßig werden vier Leerzeichen für eine Ebene genutzt.\n", + "\n", + "Diese Einrückung ist zum Beispiel bei der Definition von Methoden\n", + "\n", + "```python\n", + "def method_name(input_parameter: type_hint = default_wert) -> return_type_hint:\n", + " ...\n", + "```\n", + "\n", + "und der Definition von Klassen\n", + "\n", + "```python\n", + "class class_name:\n", + " ...\n", + "```\n", + "\n", + "relevant." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "902a4f49-f459-488b-82de-c4003df2f5bf", + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "# Definition sie die Funktion 'pretty_print_birthday'\n", + "# 1. Eingabeparameter ist das Tupel 'birthday'.\n", + "# 2. Es gibt keinen Rückgabewert (type hint == None).\n", + "# 3. Das Datum wird im Format 'Geburtstag: dd.mm.yyyy' ausgegeben.\n", + "\n", + "def pretty_print_..." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bd27a204", + "metadata": {}, + "outputs": [], + "source": [ + "# Testen sie durch ausführen diese Zelle ob ihre Funktion korrekt funktioniert.\n", + "pretty_print_birthday(birthday)" + ] + }, + { + "cell_type": "markdown", + "id": "f56137cb-1bef-460e-9066-591cdf70b651", + "metadata": {}, + "source": [ + "### Listen" + ] + }, + { + "cell_type": "markdown", + "id": "32f84ec1", + "metadata": {}, + "source": [ + "Eigenschaften aller Listen in Python:\n", + "- Die Indexierung startet bei 0.\n", + "- Elemente können einzeln oder in slices (Bereichen) abgerufen werden.\n", + "- Der Datentyp innerhalb einer Liste kann variieren\n", + "\n", + "Es gibt drei wesentliche Arten von Listen:\n", + "- Ungeordnete Listen variabler Länge: List\n", + "- Geordnete Listen variabler Länge: Set\n", + "- Geordnete Listen fester Länge: Tupel" + ] + }, + { + "cell_type": "markdown", + "id": "adb40190", + "metadata": {}, + "source": [ + "#### List" + ] + }, + { + "cell_type": "markdown", + "id": "8b2d570a", + "metadata": {}, + "source": [ + "```python\n", + "list_name: list[type_hints] = [wert1, ...]\n", + "```\n", + "- Werden keine Werte angegeben handelt es sich um eine leere Liste.\n", + "- Es können mehrere type hints angegeben werden.\n", + "\n", + "**Wichtige Funktionen:**\n", + "- Anfügen eines Eintrags: `list_name.append(wert)`\n", + "- Anfügen mehrerer Einträge: `list_name += [wert1, wert2, ...]`\n", + "- Länge der Liste: `len(list_name)`\n", + "- Abrufen eines Elementes: `list_name[index]`\n", + "- Abrufen eines Bereiches: `list_name[index_start:index_end]` (exklusive `index_end`)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "32199070", + "metadata": {}, + "outputs": [], + "source": [ + "# Legen sie eine Liste mit den Elementen 'Hello', 'World' an\n", + "\n", + "hello: ..." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5e7c8db8", + "metadata": {}, + "outputs": [], + "source": [ + "# Fügen sie an die Liste 'hello' ein '!' an\n", + "\n", + "..." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0465de17", + "metadata": {}, + "outputs": [], + "source": [ + "# Geben sie \"Hello !\" aus\n", + "\n", + "print(f\"...\")" + ] + }, + { + "cell_type": "markdown", + "id": "d73b480b", + "metadata": {}, + "source": [ + "#### Tupel" + ] + }, + { + "cell_type": "markdown", + "id": "90cfcd11", + "metadata": {}, + "source": [ + "```python\n", + "tuple_name: tuple[type_hints] = (wert1, ...)\n", + "```\n", + "- Werden keine Werte angegeben handelt es sich um ein leeres Tuple.\n", + "- Es können type hints für jedes Element angegeben werden\n", + " - Das Tuple hat dann eine feste Länge\n", + " - Der type hint gibt den Type des Wertes mit dem selben index an\n", + "- Es kann ein type hint gefolgt von `, ...` angegeben werden\n", + " - Die Länge des Tupel ist variable\n", + " - Jeder Wert hat den Typ des type hints\n", + "\n", + "**Wichtige Funktionen:**\n", + "- Länge der Liste: `len(tuple_name)`\n", + "- Abrufen eines Elementes: `tuple_name[index]`\n", + "- Abrufen eines Bereiches: `tuple_name[index_start:index_end]` (exklusive `index_end`)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "581b71fa", + "metadata": {}, + "outputs": [], + "source": [ + "# ermitteln sie die Länge der des Tupels 'birthday'\n", + "\n", + "..." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1659a719", + "metadata": {}, + "outputs": [], + "source": [ + "# Tauschen sie den Eintrag von Jahr und Tag\n", + "\n", + "day: int = ..." + ] + }, + { + "cell_type": "markdown", + "id": "da6e2614-a731-4a9e-a1ea-51bc249a5f2d", + "metadata": {}, + "source": [ + "### Dictionaries" + ] + }, + { + "cell_type": "markdown", + "id": "a85b252e", + "metadata": {}, + "source": [ + "```python\n", + "dict_name: [type_hint_key, type_hints_values] = {schlüssel1: wert1, schlüssel2: ...}\n", + "```\n", + "\n", + "- Werden keine Werte angegeben, so ist das Dictionary leer\n", + "- Der Typ des Schlüssels ist im gesamten Dictionary gleich\n", + "- Der Typ des Wertes kann variabel sein\n", + " - Die type hints werden in der Form `type_hint | type_hint | ...` angegeben\n", + "\n", + "**Wichtige Funktionen:**\n", + "- Einen Eintrag einfügen/ändern: `dict_name[schlüssel] = wert`\n", + "- Mehrere Einträge einfügen/ändern: `dict_name.update(dict_to_update)`\n", + "- Länge des Dictionaries: `len(dict_name)`\n", + "- Zugriff auf einen Eintrag: `dict_name[schlüssel]`\n", + "- Liste aller schlüssel: `dict_name.keys()`\n", + "- Liste aller Werte: `dict_name.values()`\n", + "- Liste aller Einträge als Tupel: `dict_name.items()`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3ee91955", + "metadata": {}, + "outputs": [], + "source": [ + "# Legen sie ein Dictionary mit Strings als Schlüssel und Werten vom Typ String und Tuple (int, int, int) an\n", + "# Es soll die Felder: 'name', 'birthday' haben\n", + "# Weisen sie den Feldern die passenden Daten zu\n", + "\n", + "person: ..." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1967b604", + "metadata": {}, + "outputs": [], + "source": [ + "# Geben sie durch ausführen dieser Zelle das Dictionary aus\n", + "print(person)" + ] + }, + { + "cell_type": "markdown", + "id": "016d9bcf-7341-471e-a226-92e300ba6ca3", + "metadata": {}, + "source": [ + "### Kontrollfluss" + ] + }, + { + "cell_type": "markdown", + "id": "86be7cfe-a84d-4d18-b8c8-5006f45b31c6", + "metadata": {}, + "source": [ + "#### Bedingte Statements" + ] + }, + { + "cell_type": "markdown", + "id": "dd7a3d88", + "metadata": {}, + "source": [ + "Verzweigungen können in Python durch if-else Statements oder switch-case Statements realisiert werden.\n", + "\n", + "**If-Else:**\n", + "\n", + "```python\n", + "if bool_value:\n", + " print(\"Case True\")\n", + "# else if\n", + "elif second_bool_value:\n", + " print(\"Case Two\")\n", + "else:\n", + " print(\"Else\")\n", + "```\n", + "\n", + "**Switch-Case:**\n", + "\n", + "```python\n", + "match value_to_match:\n", + " case case_1:\n", + " print(\"case 1\")\n", + " break\n", + " case case_2:\n", + " print(\"case 2\")\n", + " case case_3:\n", + " print(\"case 3\")\n", + " case _:\n", + " print(\"default case\") \n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f38f8f6b-e892-4b5b-8c54-af7ced52ad78", + "metadata": {}, + "outputs": [], + "source": [ + "# Schreibe ein Methode welche den Namen des Monats zurück gibt.\n", + "\n", + "def name_of_month(month: int) -> str | None:\n", + " name: str | None = None\n", + " \n", + " ...\n", + " \n", + " return name\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "377362d4", + "metadata": {}, + "outputs": [], + "source": [ + "# Testen sie die Methode indem sie ihre Geburtsmonat ausgeben lassen\n", + "print(name_of_month(birthday(1)))" + ] + }, + { + "cell_type": "markdown", + "id": "b1780b0b-0bd5-4a09-9651-9e2662341de3", + "metadata": {}, + "source": [ + "### Schleifen" + ] + }, + { + "cell_type": "markdown", + "id": "7bfa0bbd", + "metadata": {}, + "source": [ + "In Python gibt es _for_ und _while_ Schleifen.\n", + "\n", + "**for-Schleife:**\n", + "```python\n", + "for iterator:\n", + " do_something\n", + "```\n", + "\n", + "- Um eine Schleife x mal auszuführen benutzt man als iterator `i = range(x)`\n", + "- Um über eine Liste zu iterieren nutzt man `value in list`\n", + " - Mit Index: `index, value in enumerate(list)`\n", + "\n", + "**while-Schleife:**\n", + "```python\n", + "while bool_value:\n", + " do_something\n", + "```\n", + "\n", + "- Setzt man den `bool_value` auf `True` terminiert die Schleife nie\n", + "- Eine Do-While Schleife gibt es nicht direkt!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a4bad5e0", + "metadata": {}, + "outputs": [], + "source": [ + "# Iterieren sie mit einer for-Schleife über die Liste 'hello' und geben den Eintrag mit dem Index aus\n", + "\n", + "for index, value in ..." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "07d1a248", + "metadata": {}, + "outputs": [], + "source": [ + "# Schreiben sie eine while-Schleife, welche alle ganzzahligen Werte im Bereich von 0 bis 10 ausgibt\n", + "\n", + "while ..." + ] + }, + { + "cell_type": "markdown", + "id": "e3a19b36", + "metadata": {}, + "source": [ + "### Externe Module" + ] + }, + { + "cell_type": "markdown", + "id": "a1ede015", + "metadata": {}, + "source": [ + "Mit _import_ ist es Möglich externe Module zu importieren und diese im eigenen Code zu benutzen.\n", + "\n", + "```python\n", + "import modul_zum_importieren as internal_name\n", + "\n", + "from bibliothek import funktion_zum_importieren, symbol_zum_importieren\n", + "```\n", + "- Mit dem Schlüsselwort _as_ lässt sich dem importierten Symbol/Funktion/Modul ein eigener interner Name zuweisen.\n", + " Dies ist optional!\n", + "- Die _from_ basierte Syntax erlaubt es nur Teile eines Moduls zu importieren.\n", + " Der Vorteil dieser Vorgehensweise ist es die Abhängigkeiten genauer aufzuzeigen.\n", + "- Pfade werden mit einem Punkt getrennt: `your.custom.package`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "acf037d3", + "metadata": {}, + "outputs": [], + "source": [ + "# importieren sie das Modul 'math'\n", + "\n", + "...\n", + "\n", + "math.sqrt(4)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a1a5bf47", + "metadata": {}, + "outputs": [], + "source": [ + "# Importieren sie die Funktion 'greet' aus der Datei 'src.greetings'\n", + "\n", + "from ...\n", + "\n", + "print(greet())" + ] + }, + { + "cell_type": "markdown", + "id": "f0660cde", + "metadata": {}, + "source": [ + "### Error Handling" + ] + }, + { + "cell_type": "markdown", + "id": "5c8f3eab", + "metadata": {}, + "source": [ + "Python bietet Exceptions an um Fehler weiterzugeben und abzufangen.\n", + "\n", + "Mit der try-catch Syntax\n", + "\n", + "```python\n", + "try:\n", + " do_something()\n", + "except Exception as exp:\n", + " handle_exception()\n", + "finally:\n", + " always_execute()\n", + "```\n", + "\n", + "lassen sich Fehler abfangen, welche im _try_-Block ausgelöst werden.\n", + "\n", + "- Im _except_-Block werden nur Exceptions vom angegeben Typ abgefangen und behandelt.\n", + "- Der _finally_-Block wird in jedem Fall am Ende ausgeführt." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5c0b85ac", + "metadata": {}, + "outputs": [], + "source": [ + "try:\n", + " result = 10 / 0\n", + " \n", + "# Fangen sie den 'ZeroDivisionError' ab\n", + "except ..." + ] + }, + { + "cell_type": "markdown", + "id": "b491c200-6071-42e6-a00f-556c2994382f", + "metadata": {}, + "source": [ + "## Objekt-Orientierte Programmierung (OOP) " + ] + }, + { + "cell_type": "markdown", + "id": "2db5aba8", + "metadata": {}, + "source": [ + "Python unterstützt OOP Konzepte wie Klassen, Interfaces, Kapselung und Objekte." + ] + }, + { + "cell_type": "markdown", + "id": "4b27c36a-0c42-46c9-8ab9-09e8edfa88d7", + "metadata": {}, + "source": [ + "### Interface Klassen" + ] + }, + { + "cell_type": "markdown", + "id": "e267cc8d", + "metadata": {}, + "source": [ + "- Interface Klassen werden durch ihre Vererbung von `ABC` kenntlich gemacht\n", + "- Abstrakte Methoden durch die Annotation `@abstractmethod` an der Definition" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f627ff43-64f9-4f51-b5f8-ca8b7d29ba8f", + "metadata": {}, + "outputs": [], + "source": [ + "# Definieren sie eine Interface Klasse 'Greetings'\n", + "# Diese Klasse soll die abstrakte Methode 'greet' enthalten\n", + "# Der Körper der Methode ist leer und besteht nur aus dem Schlüsselword 'pass'\n", + "\n", + "from abc import ABC, abstractmethod\n", + "\n", + "class ...\n", + " @abstractmethod\n", + " def ..." + ] + }, + { + "cell_type": "markdown", + "id": "78dd149b-074e-4b9d-9ec7-4206c7063dd7", + "metadata": {}, + "source": [ + "**💡** Interface Klassen können nicht direkt instanziiert werden, da sie abstrakte Methoden enthalten. " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9844c1fb-a4c9-4ecb-a731-6bb12d9387b1", + "metadata": {}, + "outputs": [], + "source": [ + "humanoid = Humanoid()" + ] + }, + { + "cell_type": "markdown", + "id": "65bd44ae-2b78-4ea8-ad92-86036cf017a8", + "metadata": {}, + "source": [ + "### Definieren einer Klasse" + ] + }, + { + "cell_type": "markdown", + "id": "8c08ea00", + "metadata": {}, + "source": [ + "- Eine Klasse wird durch das Schlüsselword `class` kenntlich gemacht\n", + "- Das Interface welches implementiert wird ist in Klammern hinter dem Namen der Klasse angegeben\n", + "- Eine Instanz der Klasse wird erzeugt durch den Aufruf des Klassennamens gefolgt von Klammern\n", + " - Dieser Aufrauf enthält als Parameter die Argumente der `__init__` Funktion" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "59075058-21ec-489d-951c-89a7f8d32672", + "metadata": {}, + "outputs": [], + "source": [ + "# Implementieren sie die Klasse 'German'\n", + "# Diese Klasse soll vom Interface 'Greetings' erben und die Methode 'greet' implementieren\n", + "\n", + "class ..." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "44883941", + "metadata": {}, + "outputs": [], + "source": [ + "# Instanziieren sie die Klasse 'German' und führen sie die Methode 'greet' aus\n", + "# Die Methode 'greet' soll den Satz \"Guten Tag.\" ausgegeben\n", + "\n", + "german = ..." + ] + }, + { + "cell_type": "markdown", + "id": "e355397c-4a79-4d66-9e1b-36593149f141", + "metadata": {}, + "source": [ + "### Vererbung" + ] + }, + { + "cell_type": "markdown", + "id": "78652977", + "metadata": {}, + "source": [ + "- Die Klasse von der geerbt werden soll wird wie bei Interface Klassen in Klammern hinter dem Namen angebenden\n", + "- Der Aufruf der Basis Klasse erfolgt über `super()`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4b3b8daa", + "metadata": {}, + "outputs": [], + "source": [ + "# Implementieren sie die Klasse 'Ruhrpott' \n", + "# Diese Klasse soll von 'German' erben\n", + "# Überschreiben sie die Methode 'greet', so dass sie \"Tach.\" zurück gibt\n", + "\n", + "class Ruhrpott(..." + ] + }, + { + "cell_type": "markdown", + "id": "0bb8d3e9", + "metadata": {}, + "source": [ + "---\n", + "\n", + "Sie haben nun das Kapitel Python Grundlagen abgeschlossen.\n", + "Im nächsten Kapitel geht es um die Bibliothek numpy.\n", + "\n", + "**[WEITER (Numpy)](./03_Numpy.ipynb)**" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "test-binder", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/03_Numpy.ipynb b/03_Numpy.ipynb new file mode 100644 index 0000000..5bf6b78 --- /dev/null +++ b/03_Numpy.ipynb @@ -0,0 +1,349 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "b739152c-75cb-4fd2-9ce8-123c40a5deb1", + "metadata": {}, + "source": [ + "# Einführung in NumPy" + ] + }, + { + "cell_type": "markdown", + "id": "78361c20", + "metadata": {}, + "source": [ + "[NumPy](https://numpy.org/doc/stable/) ist eine Python-Bibliothek für numerische Berechnungen. \n", + "Sie bietet Werkzeuge für die Arbeit mit Arrays, Matrizen und einer Vielzahl von mathematischen Operationen.\n", + "\n", + "Das nachfolgende Tutorial möchte am Beispiel der Bildverarbeitung die Grundlegenden Funktionen von NumPy zeigen und die Bibliothek so näher bringen.\n", + "\n", + "> **TIP:** [NumPy API Reference](https://numpy.org/doc/stable/reference/routines.html)" + ] + }, + { + "cell_type": "markdown", + "id": "65665577-af01-4034-b94f-5bb81fa6c16c", + "metadata": {}, + "source": [ + "## NumPy Importieren" + ] + }, + { + "cell_type": "markdown", + "id": "2245019a", + "metadata": {}, + "source": [ + "Damit können wir die Funktionen von NumPy verwenden können müssen wir zunächst die Bibliothek importieren.\n", + "Hierfür hat es sich eingespielt die Bibliothek später nur noch `np` zu nennen." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9baea2a9-d139-456c-857d-35ce9dce82f6", + "metadata": {}, + "outputs": [], + "source": [ + "# Importieren sie die Bibliothek 'numpy' und nennen diese 'np'\n", + "import ..." + ] + }, + { + "cell_type": "markdown", + "id": "ef264ef6", + "metadata": {}, + "source": [ + "## Arrays anlegen" + ] + }, + { + "cell_type": "markdown", + "id": "1f66da4b", + "metadata": {}, + "source": [ + "Ein Wichtige Aspekt besteht in der Interpretation von Daten als Matrize (oder Array).\n", + "Diese Arrays können mit NumPy einfach angelegt werden.\n", + "\n", + "Es handelt sich hierbei um eine spezielle Form von Listen.\n", + "Eine wichtige Eigenschaft dieser NumPy Arrays besteht darin, dass sie nur Element **eines** fest definierten Datentyps enthalten können.\n", + "Die zu Verfügung stehenden Datentypen werden hierbei durch NumPy vorgegeben\n", + "\n", + "- Vorzeichen behaftete Integer Datentypen:\n", + " - `int8` -> signed 8 Bit Ganzzahl (char)\n", + " - `int16` -> signed 16 Bit Ganzzahl (short)\n", + " - `int32` -> signed 32 Bit Ganzzahl (int)\n", + " - `int64` -> signed 64 Bit Ganzzahl (long)\n", + "- Vorzeichen freie Integer Datentypen:\n", + " - `bool` -> Boolean\n", + " - `int8` -> unsigned 8 Bit Ganzzahl (uchar)\n", + " - `int16` -> unsigned 16 Bit Ganzzahl (ushort)\n", + " - `int32` -> unsigned 32 Bit Ganzzahl (uint)\n", + " - `int64` -> unsigned 64 Bit Ganzzahl (ulong)\n", + "- Fließkommazahlen:\n", + " - `float16` -> Half precision Float (16 Bit)\n", + " - `float32` -> Float (32 Bit)\n", + " - `float64` -> Double (64 Bit)\n", + " - `float128` -> Long Double (128 Bit)\n", + "- Komplexe Zahlen:\n", + " - `complex64` -> Komplexe Zahl (Dargestellt durch zwei 32 Bit Floats)\n", + " - `complex128` -> Komplexe Zahl (Dargestellt durch zwei 64 Bit Double)\n", + " - `complex256` -> Komplexe Zahl (Dargestellt durch zwei 128 Bit Long Double)\n", + "\n", + "Der Datentyp eines Arrays lässt sich mit Hilfe der Funktion\n", + "\n", + "```python\n", + "numpy_array.astype(np.numpy_type)\n", + "```\n", + "\n", + "konvertieren.\n", + "\n", + "Um ein Array anzulegen stehen mehrere Funktionen zur Verfügung\n", + "\n", + "- `np.zeros((x,y))` -> Array mit x Zeilen und y Spalten, wobei alle Elemente 0 sind\n", + "- `np.ones((x,y))` -> Array mit x Zeilen und y Spalten, wobei alle Elemente 1 sind\n", + "- `np.eye(w)` -> (Quadratische) 2D Identitätsmatrix \n", + "- `np.arrange(start, end, step)` -> Array mit Werten von _start_ bis _end_ in Schritten ger Größe _step_\n", + "- `np.asarray([...])` -> Konvertiert eine Liste von Zahlen in ein NumPy Array\n", + "- ..." + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "id": "f79fba13", + "metadata": {}, + "outputs": [], + "source": [ + "# Legen sie nun ein zweites Array an\n", + "# - Größe 256 mal 0\n", + "# - Alle Elemente sollen den Wert 0 haben\n", + "# der Datentyp soll auf 'int8' festgelegt werden\n", + "\n", + "black_line: np.ndarray = ..." + ] + }, + { + "cell_type": "markdown", + "id": "ebd784f5", + "metadata": {}, + "source": [ + "## Erweiterung" + ] + }, + { + "cell_type": "markdown", + "id": "9de24049", + "metadata": {}, + "source": [ + "NumPy expandiert kleinere Arrays automatisch, um sie an die Form größerer Arrays anzupassen.\n", + "\n", + "Im folgenden Beispiel wird die Zahl 255 expandiert zu `[255, 255, ...]` und anschließend eine Elementweise Addition durchgeführt." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "38908bea", + "metadata": {}, + "outputs": [], + "source": [ + "# addieren sie den Wert 255 zu jedem Wert im Array 'black_line'\n", + "\n", + "black_line += ..." + ] + }, + { + "cell_type": "markdown", + "id": "8115c6da", + "metadata": {}, + "source": [ + "## Array Indizierung" + ] + }, + { + "cell_type": "markdown", + "id": "ff76f207", + "metadata": {}, + "source": [ + "Der Zugriff auf Elemente eines NumPy Arrays funktioniert ähnlich wie bei normalen Listen in Python.\n", + "Die Daten können mittels des Index (starte bei 0) abgerufen werden.\n", + "Da Arrays meist mehrere Dimensionen haben ist dies beim Zugriff zu berücksichtigen:\n", + "\n", + "```python\n", + "array_slice: np.ndarray = numpy_array[x,y,...]\n", + "```\n", + "Die gewünschten Indizes der Dimensionen werden hierbei durch Komma (`,`) getrennt angeben.\n", + "Jede Angabe kann hier wie bei Listen üblich aus einem einzelnen Index, oder einem Bereich bestehen.\n", + "Um all Einträge in einer Dimension auszuwählen kann man vereinfacht nur `:` angeben." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "925b9173", + "metadata": {}, + "outputs": [], + "source": [ + "# Lassen sie sich das erste Element des Array 'raw_img' ausgeben\n", + "black_line[..." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "354313a9", + "metadata": {}, + "outputs": [], + "source": [ + "# Lassen sie sich nun die ersten 10 Elemente der 10. Zeile ausgeben\n", + "black_line[..." + ] + }, + { + "cell_type": "markdown", + "id": "91c163dc", + "metadata": {}, + "source": [ + "## Daten manipulieren" + ] + }, + { + "cell_type": "markdown", + "id": "58d15daf", + "metadata": {}, + "source": [ + "NumPy bietet viele Funktionen um Daten zu manipulieren.\n", + "\n", + "- Addition: `numpy_array_1 + numpy_array_2`\n", + "- Multiplikation: `np.dot(numpy_array_1, numpy_array_2)`\n", + "- Transposition: `np.transpose(numpy_array_1)`\n", + "- Reshape: `np.reshape(numpy_array_1, (axis_1, ...))`\n", + "- Diagonale ersetzen: `np.diag()`\n", + "\n", + "> **TIP**:\n", + "> Um einen Zeilenvektor in einen Spaltenvektor umzuwandeln muss das Array **zwei** dimensional sein!\n", + "> Mit der Funktion `np.atleast_2d()` kann dies sichergestellt werden." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fb2363f7", + "metadata": {}, + "outputs": [], + "source": [ + "# Legen sie ein Array an, welches das Array 'black_line' als Diagonale enthält.\n", + "\n", + "backslash: np.ndarray = ..." + ] + }, + { + "cell_type": "markdown", + "id": "00051455", + "metadata": {}, + "source": [ + "## Daten auswerten" + ] + }, + { + "cell_type": "markdown", + "id": "3b786d0b", + "metadata": {}, + "source": [ + "Zusätzlich zur Auswertung der Daten bietet NumPy auch die Möglichkeit Informationen über das Array zu ermitteln.\n", + "\n", + "- Durchschnitt: `np.mean(numpy_array)`\n", + "- Summe: `np.sum(numpy_array)`\n", + "- Maximum: `np.max(numpy_array)`\n", + "- Minimum: `np.min(numpy_array)`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0658a111", + "metadata": {}, + "outputs": [], + "source": [ + "# Ermitteln sie das Minimum des Arrays\n", + "\n", + "..." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fab84f3e", + "metadata": {}, + "outputs": [], + "source": [ + "# Ermitteln sie das Maximum des Arrays\n", + "\n", + "..." + ] + }, + { + "cell_type": "markdown", + "id": "3f0aec32", + "metadata": {}, + "source": [ + "## Backslash anzeigen" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d764b92d", + "metadata": {}, + "outputs": [], + "source": [ + "# Importieren der Bibliothek zur Darstellung\n", + "from matplotlib import pyplot as plt\n", + "\n", + "# Anzeigen des Arrays\n", + "plt.imshow(\n", + " backslash, # Array zum anzeigen\n", + " vmin=0, # Minimal Wert\n", + " vmax=255, # Maximal Wert\n", + " cmap=\"Greys\" # Graustufen für Darstellung\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "431302ca-26e0-4ca1-878f-e8b0ef9f7a28", + "metadata": {}, + "source": [ + "---\n", + "\n", + "**🎉 Herzlichen Glückwunsch. Sie haben unser Tutorial abgeschlossen.**\n", + "\n", + "Wenn sie Interesse an weiteren tiefer gehenden Beispielen haben können sie sich diese anschauen:\n", + "- [Numpy Example](numpy_sample.ipynb)\n", + "- [Configuration Loader](loader_sample.ipynb)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "test-binder", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/devenv.nix b/devenv.nix index 7adbe61..d1e6446 100644 --- a/devenv.nix +++ b/devenv.nix @@ -1,49 +1,26 @@ { pkgs, lib, config, inputs, ... }: { - # https://devenv.sh/basics/ - env.GREET = "devenv"; - - # https://devenv.sh/packages/ packages = [ pkgs.git - pkgs.just - pkgs.uv ]; - # https://devenv.sh/languages/ - # languages.rust.enable = true; - - # https://devenv.sh/processes/ - # processes.cargo-watch.exec = "cargo-watch"; - - # https://devenv.sh/services/ - # services.postgres.enable = true; - - # https://devenv.sh/scripts/ - scripts.hello.exec = '' - echo hello from $GREET - ''; + languages.python = { + enable = true; + package = pkgs.python311; + venv.enable = true; + venv.quiet = true; + uv = { + enable = true; + package = pkgs.uv; + sync.enable = true; + sync.allExtras = true; + }; + }; enterShell = '' - hello - git --version + echo + echo "Welcome Back!" + echo ''; - - # https://devenv.sh/tasks/ - # tasks = { - # "myproj:setup".exec = "mytool build"; - # "devenv:enterShell".after = [ "myproj:setup" ]; - # }; - - # https://devenv.sh/tests/ - enterTest = '' - echo "Running tests" - git --version | grep --color=auto "${pkgs.git.version}" - ''; - - # https://devenv.sh/git-hooks/ - # git-hooks.hooks.shellcheck.enable = true; - - # See full reference at https://devenv.sh/reference/options/ } diff --git a/loader_sample.ipynb b/loader_sample.ipynb index a659b8b..0c064de 100644 --- a/loader_sample.ipynb +++ b/loader_sample.ipynb @@ -43,7 +43,7 @@ }, { "cell_type": "code", - "execution_count": 104, + "execution_count": null, "id": "89968951-0c97-4a17-acdd-b6d1e680e24b", "metadata": {}, "outputs": [], @@ -68,7 +68,7 @@ }, { "cell_type": "code", - "execution_count": 110, + "execution_count": null, "id": "89dbaac8-d370-4c1a-b93b-a0677ed6ae7f", "metadata": {}, "outputs": [], @@ -122,7 +122,7 @@ }, { "cell_type": "code", - "execution_count": 111, + "execution_count": null, "id": "2b30fc6e-a8e3-49e3-b104-96d459dbb483", "metadata": {}, "outputs": [], @@ -165,7 +165,7 @@ }, { "cell_type": "code", - "execution_count": 118, + "execution_count": null, "id": "2cf37b07-7c42-4a56-9aa7-2f1d81ff50a7", "metadata": {}, "outputs": [], @@ -176,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": 119, + "execution_count": null, "id": "3961f39f-6723-455f-9fc5-0068bbd85068", "metadata": {}, "outputs": [], @@ -186,7 +186,7 @@ }, { "cell_type": "code", - "execution_count": 120, + "execution_count": null, "id": "2a8fff4d-058d-4b65-87aa-cdbc291e50e4", "metadata": {}, "outputs": [], @@ -238,46 +238,10 @@ }, { "cell_type": "code", - "execution_count": 121, + "execution_count": null, "id": "0b28d0dd-a2d9-4f58-8f77-1794509d073d", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[1m======================================= test session starts ========================================\u001b[0m\n", - "platform linux -- Python 3.11.11, pytest-8.3.5, pluggy-1.6.0 -- /home/federl_david/Repositories/ZaKID/test-binder/.venv/bin/python3\n", - "cachedir: .pytest_cache\n", - "rootdir: /home/federl_david/Repositories/ZaKID/test-binder\n", - "configfile: pyproject.toml\n", - "plugins: anyio-4.9.0, mock-3.14.1\n", - "\u001b[1mcollecting ... \u001b[0mcollected 9 items\n", - "\n", - "t_3b90d0ce4a8e49f5ac1806f203f221de.py::test_interface_cant_be_instaniated \u001b[32mPASSED\u001b[0m\u001b[32m [ 11%]\u001b[0m\n", - "t_3b90d0ce4a8e49f5ac1806f203f221de.py::test_interface_has_abstractmethod_load \u001b[32mPASSED\u001b[0m\u001b[32m [ 22%]\u001b[0m\n", - "t_3b90d0ce4a8e49f5ac1806f203f221de.py::test_interface_has_abstractmethod_save \u001b[32mPASSED\u001b[0m\u001b[32m [ 33%]\u001b[0m\n", - "t_3b90d0ce4a8e49f5ac1806f203f221de.py::test_yamlloader_can_be_instaniated \u001b[32mPASSED\u001b[0m\u001b[32m [ 44%]\u001b[0m\n", - "t_3b90d0ce4a8e49f5ac1806f203f221de.py::test_yamlloader_has_method_load \u001b[32mPASSED\u001b[0m\u001b[32m [ 55%]\u001b[0m\n", - "t_3b90d0ce4a8e49f5ac1806f203f221de.py::test_yamlloader_has_method_save \u001b[32mPASSED\u001b[0m\u001b[32m [ 66%]\u001b[0m\n", - "t_3b90d0ce4a8e49f5ac1806f203f221de.py::test_jsonloader_can_be_instaniated \u001b[32mPASSED\u001b[0m\u001b[32m [ 77%]\u001b[0m\n", - "t_3b90d0ce4a8e49f5ac1806f203f221de.py::test_jsonloader_has_method_load \u001b[32mPASSED\u001b[0m\u001b[32m [ 88%]\u001b[0m\n", - "t_3b90d0ce4a8e49f5ac1806f203f221de.py::test_jsonloader_has_method_save \u001b[32mPASSED\u001b[0m\u001b[32m [100%]\u001b[0m\n", - "\n", - "\u001b[32m======================================== \u001b[32m\u001b[1m9 passed\u001b[0m\u001b[32m in 0.01s\u001b[0m\u001b[32m =========================================\u001b[0m\n" - ] - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 121, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "ipytest.run(\"-vv\")" ] @@ -285,7 +249,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "test-binder", "language": "python", "name": "python3" }, @@ -299,7 +263,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.11" + "version": "3.11.12" } }, "nbformat": 4, diff --git a/numpy_sample.ipynb b/numpy_sample.ipynb index 4285524..5df0e7a 100644 --- a/numpy_sample.ipynb +++ b/numpy_sample.ipynb @@ -325,7 +325,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "test-binder", "language": "python", "name": "python3" }, @@ -339,7 +339,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.11" + "version": "3.11.12" } }, "nbformat": 4, diff --git a/numpy_tutorial.ipynb b/numpy_tutorial.ipynb deleted file mode 100644 index 34eda1e..0000000 --- a/numpy_tutorial.ipynb +++ /dev/null @@ -1,308 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "b739152c-75cb-4fd2-9ce8-123c40a5deb1", - "metadata": {}, - "source": [ - "# **Einführung in NumPy** **_Introduction to NumPy_**\n", - "\n", - "[NumPy](https://numpy.org/doc/stable/) ist eine grundlegende Python-Bibliothek für numerische Berechnungen. Sie bietet Werkzeuge für die Arbeit mit Arrays, Matrizen und einer Vielzahl von mathematischen Funktionen.\n", - "\n", - "_[NumPy](https://numpy.org/doc/stable/) is a fundamental Python library for numerical computing. It provides tools to work with arrays, matrices, and a host of mathematical functions._" - ] - }, - { - "cell_type": "markdown", - "id": "65665577-af01-4034-b94f-5bb81fa6c16c", - "metadata": {}, - "source": [ - "## 1. NumPy Importieren _Import NumPy_\n", - "\n", - "Damit können wir die Funktionen von NumPy verwenden, indem wir ihnen den Präfix `np` voranstellen.\n", - "\n", - "_This allows you to use NumPy’s functions by prefixing them with `np`._" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "9baea2a9-d139-456c-857d-35ce9dce82f6", - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np" - ] - }, - { - "cell_type": "markdown", - "id": "53e52a29-fc4d-46da-85af-fa0eb56ef87e", - "metadata": {}, - "source": [ - "## 3. Arrays anlegen _Creating Arrays_" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "efacb357-7e82-46c2-abbc-537b647ab5e4", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1 2 3 4]\n", - "[[1 2 3]\n", - " [4 5 6]]\n" - ] - } - ], - "source": [ - "# 1D Array (Vector)\n", - "arr = np.array([1, 2, 3, 4])\n", - "print(arr)\n", - "\n", - "# 2D Array (Matrix)\n", - "arr_2d = np.array([[1, 2, 3], [4, 5, 6]])\n", - "print(arr_2d)\n", - "\n", - "# Special Arrays\n", - "zeros = np.zeros((2, 3)) # 2x3 array of zeros\n", - "ones = np.ones((3, 2)) # 3x2 array of ones\n", - "identity = np.eye(3) # 3x3 identity matrix" - ] - }, - { - "cell_type": "markdown", - "id": "7afcb950-1e1c-4501-98e1-51065e26511c", - "metadata": {}, - "source": [ - "## 3. Array Operationen _Array Operations_\n", - "\n", - "NumPy ermöglicht elementweise Operationen und unterstützt Matrixoperationen.\n", - "\n", - "_NumPy enables element-wise operations and supports matrix operations._" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "2253194d-14a8-4ffb-928d-eda3bcdce71c", - "metadata": {}, - "outputs": [], - "source": [ - "# Element-wise addition\n", - "arr_a = np.array([1, 2, 3])\n", - "arr_b = np.array([4, 5, 6])\n", - "sum_arr = arr_a + arr_b\n", - "\n", - "# Matrix Multiplication\n", - "matrix_a = np.array([[1, 2], [3, 4]])\n", - "matrix_b = np.array([[5, 6], [7, 8]])\n", - "result = np.dot(matrix_a, matrix_b)" - ] - }, - { - "cell_type": "markdown", - "id": "91a90eda-624b-4c0a-94bc-cea860c4e4b4", - "metadata": {}, - "source": [ - "## 4. Indizierung _Indexing_\n", - "\n", - "Der Zugriff auf Elemente funktioniert wie bei normalen Listen in Python.\n", - "\n", - "_Works like normal lists in Python._" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "8b594d74-0fd1-439d-a312-dd24b5a3c24f", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "30\n", - "[1 2 3]\n", - "[4 5 6]\n" - ] - } - ], - "source": [ - "# Accessing elements\n", - "arr = np.array([10, 20, 30, 40])\n", - "print(arr[2])\n", - "\n", - "# Slicing\n", - "arr = np.array([0, 1, 2, 3, 4, 5])\n", - "print(arr[1:4])\n", - "\n", - "# Multidimensional Slicing\n", - "arr_2d = np.array([[1, 2, 3], \n", - " [4, 5, 6]])\n", - "print(arr_2d[1, :])" - ] - }, - { - "cell_type": "markdown", - "id": "73ffa320-a82d-43b4-bedb-09000cbb1840", - "metadata": {}, - "source": [ - "## 5. Nützliche Funktionenen _Useful Functions_" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "id": "fa922d88-eca1-46d2-a41e-430cd5da4896", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[ 0 2 4 6 8 10]\n", - "5.0\n", - "30\n", - "10\n", - "[[ 0 2 4]\n", - " [ 6 8 10]]\n" - ] - } - ], - "source": [ - "# Generating Ranges\n", - "arr = np.arange(0, 11, 2) # Array from 0 to 11 (exclusive) with step 2\n", - "print(arr)\n", - "\n", - "#Statistical Functions\n", - "print(np.mean(arr)) # Mean\n", - "print(np.sum(arr)) # Sum\n", - "print(np.max(arr)) # Maximum\n", - "\n", - "# Reshaping Arrays\n", - "reshaped = arr.reshape((2, 3)) # 2x3 array\n", - "print(reshaped)" - ] - }, - { - "cell_type": "markdown", - "id": "d1088e62-f1dd-4bfc-9842-0ff66a836b82", - "metadata": {}, - "source": [ - "## 6. Erweiterung _Broadcasting_\n", - "\n", - "NumPy expandiert kleinere Arrays automatisch, um sie an die Form größerer Arrays anzupassen.\n", - "\n", - "_NumPy automatically expands smaller arrays to match the shape of larger ones._" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "id": "91c83a28-0d2a-453f-b827-417a0795e508", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[6 7 8]\n" - ] - } - ], - "source": [ - "arr = np.array([1, 2, 3])\n", - "print(arr + 5)" - ] - }, - { - "cell_type": "markdown", - "id": "bb29a946-556a-49d2-8ecc-005f052e6e51", - "metadata": {}, - "source": [ - "## 7. Practical Applications" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "id": "f9cff28f-3a67-4755-abdb-cb497ae283f1", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[0. 0.33333333 0.66666667 1. ]\n", - "[[1. 0. 0. 0.]\n", - " [0. 1. 0. 0.]\n", - " [0. 0. 0. 1.]]\n" - ] - } - ], - "source": [ - "# Normalizing Data\n", - "data = np.array([1, 2, 3, 4])\n", - "normalized = (data - np.min(data)) / (np.max(data) - np.min(data))\n", - "print(normalized)\n", - "\n", - "# Creating One-Hot Encoded Arrays\n", - "categories = 4\n", - "indices = np.array([0, 1, 3])\n", - "one_hot = np.eye(categories)[indices]\n", - "print(one_hot)" - ] - }, - { - "cell_type": "markdown", - "id": "f9bf5a74-f75d-4907-ad14-166463ed7cc9", - "metadata": {}, - "source": [ - "## 8. Zusammenfassung _Summary_\n", - "\n", - "NumPy ist eine vielseitige Bibliothek für numerische Berechnungen. \n", - "Sie ist die Grundlage für Bibliotheken wie Pandas, Matplotlib und Scikit-learn. \n", - "Die Beherrschung von NumPy ist ein Sprungbrett für fortgeschrittene Data Science und maschinelles Lernen.\n", - "\n", - ">>>\n", - " \n", - "_NumPy is a versatile library for numerical computations._\n", - "_It is foundational for libraries like Pandas, Matplotlib, and Scikit-learn._\n", - "_Mastering NumPy is a stepping stone for advanced data science and machine learning._" - ] - }, - { - "cell_type": "markdown", - "id": "431302ca-26e0-4ca1-878f-e8b0ef9f7a28", - "metadata": {}, - "source": [ - "[NEXT (Numpy Example)](numpy_sample.ipynb)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.11" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/pyproject.toml b/pyproject.toml index 38af2e1..8fefc82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] -name = "test-binder" +name = "Python_Basic_Tutorial" version = "0.1.0" -description = "Add your description here" +description = "Python Tuttorial for Developer. Provides basic knowledge of Python, Jupyter, and Matplotlib to master our machine learning course." readme = "README.md" requires-python = ">=3.11" dependencies = [ @@ -18,6 +18,10 @@ dependencies = [ ] [dependency-groups] +dev = [ + "ipykernel>=6.29.5", + "pynvim>=0.5.2", +] local = [ "jupyter>=1.1.1", ] diff --git a/tutorial.ipynb b/tutorial.ipynb deleted file mode 100644 index 9a4c0ee..0000000 --- a/tutorial.ipynb +++ /dev/null @@ -1,796 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "f623b98c-3bd2-432b-b688-39ab4df89661", - "metadata": { - "jupyter": { - "source_hidden": true - } - }, - "outputs": [], - "source": [ - "# required for Jupyter Notebooks to include local Modules \n", - "%load_ext autoreload\n", - "%autoreload 2\n", - "\n", - "import os\n", - "import sys\n", - "module_path = os.path.abspath(os.path.join(\"src\")) # or the path to your source code\n", - "sys.path.append(module_path)" - ] - }, - { - "cell_type": "markdown", - "id": "15a90de5-8d0d-4026-950e-1dc8262b38e6", - "metadata": {}, - "source": [ - "# Python Tutorial" - ] - }, - { - "cell_type": "markdown", - "id": "1bf637e9-287b-4c7c-b723-671d0604a42d", - "metadata": {}, - "source": [ - "## 1. **Grundlagen Basics**\n", - "\n", - "Python ist für seine einfache Nutzbarkeit bekannt. Im Nachfolgenden werden einigie grundlegende Konzepte erläutert.\n", - "\n", - "_Python is known for its simplicity and readability. Below are some basic concepts_" - ] - }, - { - "cell_type": "markdown", - "id": "93bef8a9-50fe-48fe-a040-1e7261fb18f0", - "metadata": {}, - "source": [ - "**Einrückung**\n", - "- Einrückung ersetzt in Python geschweifte Klammern `{}` oder andere Gruppierungsmerkmale für Statements\n", - "\n", - "**_Indentation_**\n", - " - _Indentation replaces curly brackets `{}` or other grouping features for statements in Python_" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "902a4f49-f459-488b-82de-c4003df2f5bf", - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Adult\n" - ] - } - ], - "source": [ - "if True:\n", - " print(\"Adult\")" - ] - }, - { - "cell_type": "markdown", - "id": "781332b0-bb19-411d-9963-c5dd2273e53b", - "metadata": {}, - "source": [ - "**Ausgabe in das Terminal** \n", - "**_Print to Terminal_**" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "f84675f5-4d19-498d-baa6-a7d291286925", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello World\n" - ] - } - ], - "source": [ - "print(\"Hello World\")" - ] - }, - { - "cell_type": "markdown", - "id": "db343fb3-0dad-4e6c-927e-895a82d6f6a2", - "metadata": {}, - "source": [ - "**Variablen** \n", - "**_Variables_**" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "013b05ba-858c-41f2-9dbf-cc2266db803d", - "metadata": {}, - "outputs": [], - "source": [ - "# Strings\n", - "name = \"Alice\"\n", - "\n", - "# Integers\n", - "age = 25\n", - "\n", - "# Floats\n", - "height = 5.9\n", - "\n", - "# Booleans\n", - "is_student = False" - ] - }, - { - "cell_type": "markdown", - "id": "f56137cb-1bef-460e-9066-591cdf70b651", - "metadata": {}, - "source": [ - "**Listen** \n", - "- Listen werden in Python durch eckige Klammern `[]` kenntlich gemacht\n", - "- Die Indexierung startet bei 0\n", - "- Elemente können einzeln abgerufen werden oder in Bereichen\n", - "- Ungeordnete Liste, welche änderbar ist und Duplikate enthalten kann\n", - "\n", - "**_Lists_**\n", - "- _Lists are identified in Python by square brackets `[]`_\n", - "- _Indexing starts at 0_\n", - "- _Elements can be called up individually or in ranges_\n", - "- _Unordered list, which can be changed and may contain duplicates_" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "96f29087-e55f-43a4-b059-6647a29b0394", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n", - "World\n", - "['Hello', 'World']\n", - "Hello\n", - "World\n", - "!\n" - ] - } - ], - "source": [ - "# leere Liste (empty list)\n", - "list1 = []\n", - "\n", - "# Anfügen eines einzelnen Elements (append single elment)\n", - "list1.append(\"Hello\")\n", - "\n", - "# Anfügen mehrere Elemente (append multiple elements)\n", - "list1 += [\"World\", \"!\"]\n", - "\n", - "# Länge der Liste (list length)\n", - "print(len(list1))\n", - "\n", - "# Abruf des 2. Elements (get 2. element)\n", - "print(list1[1])\n", - "\n", - "# Abruf der beiden ersten Elemente (get the first two elements)\n", - "# End Index ist ausgenommen (end index excluded)\n", - "print(list1[0:2])\n", - "\n", - "# Iterieren über die Liste (iterate over list)\n", - "for value in list1:\n", - " print(value)" - ] - }, - { - "cell_type": "markdown", - "id": "da6e2614-a731-4a9e-a1ea-51bc249a5f2d", - "metadata": {}, - "source": [ - "**Wörterbücher**\n", - "- Wörterbücher werden in Python durch geschweifte Klammern `{}` kenntlich gemacht\n", - "- Der Typ des Schlüssels muss im gesamten Wörterbuch gleich sein\n", - "- Geordnete Liste, welche änderbar aber ist und keine Duplikate zulässt\n", - "\n", - "**_Dictionaries_**\n", - "- _Dictionaries are identified in Python by curly brackets `{}`_\n", - "- _The type of the key must be the same in the entire dictionary_\n", - "- _Ordered list, which is changeable and does not allow duplicates_" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "c1ddb540-1070-425c-a4f2-efeeb9753604", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n", - "World\n", - "key1: Hello\n", - "key2: World\n", - "key3: !\n" - ] - } - ], - "source": [ - "# leeres Wörterbuch (empty dictionary)\n", - "dict1 = {}\n", - "\n", - "# Anfügen/Ändern eines einzelnen Elements (append/update single elment)\n", - "dict1[\"key1\"] = \"Hello\"\n", - "\n", - "# Anfügen mehrere Elemente (append/update multiple elements)\n", - "dict1.update({\"key2\": \"World\", \"key3\": \"!\"})\n", - "\n", - "# Länge des Wörterbuches (dictionary length)\n", - "print(len(dict1))\n", - "\n", - "# Abruf eines Elements (get element)\n", - "print(dict1[\"key2\"])\n", - "\n", - "# Iterieren über das Wörterbuch (iterate over dictionary)\n", - "for key,value in dict1.items():\n", - " print(key + \": \" + value)" - ] - }, - { - "cell_type": "markdown", - "id": "e0663753-d73b-43db-a792-aed0a57f395d", - "metadata": {}, - "source": [ - "**Tupel**\n", - "- Tupel werden in Python durch runde Klammern `()` kenntlich gemacht\n", - "- Geordnete Liste, welche nicht änderbar ist und Duplikate zulässt\n", - "\n", - "**_Tuple_**\n", - "- _Tuples are identified in Python by round brackets `()`._\n", - "- _Ordered list, which is not changeable and allows duplicates_" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "0b7e9bac-2b97-431a-913c-cae8ddc383af", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n", - "World\n", - "Hello\n", - "World\n", - "!\n" - ] - } - ], - "source": [ - "# leeres Tupel (empty tuple)\n", - "tup1 = ()\n", - "\n", - "# Tupel mit Elementen (tuple with elements)\n", - "tup1 = (\"Hello\", \"World\", \"!\")\n", - "\n", - "# Länge des Tupels (tuple length)\n", - "print(len(tup1))\n", - "\n", - "# Abruf eines Elements (get element)\n", - "print(tup1[1])\n", - "\n", - "# Iterieren über das Wörterbuch (iterate over dictionary)\n", - "for value in tup1:\n", - " print(value)" - ] - }, - { - "cell_type": "markdown", - "id": "016d9bcf-7341-471e-a226-92e300ba6ca3", - "metadata": {}, - "source": [ - "## 2. **Kontrollfluss** **_Control Flow_**" - ] - }, - { - "cell_type": "markdown", - "id": "86be7cfe-a84d-4d18-b8c8-5006f45b31c6", - "metadata": {}, - "source": [ - "**Bedingte Statements** \n", - "**_Conditional Statements_**" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "f38f8f6b-e892-4b5b-8c54-af7ced52ad78", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Adult\n" - ] - } - ], - "source": [ - "if age < 18:\n", - " print(\"Minor\")\n", - "\n", - "# else if\n", - "elif age == 18:\n", - " print(\"Exactly 18!\")\n", - "\n", - "else:\n", - " print(\"Adult\")" - ] - }, - { - "cell_type": "markdown", - "id": "b1780b0b-0bd5-4a09-9651-9e2662341de3", - "metadata": {}, - "source": [ - "**Schleifen** \n", - "**_Loops_**" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "2df906a3-26b9-4000-a335-dc30e54b117d", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "1\n", - "2\n", - "3\n", - "4\n", - "0\n", - "1\n", - "2\n", - "3\n", - "4\n" - ] - } - ], - "source": [ - "# For loop\n", - "for i in range(5):\n", - " print(i)\n", - "\n", - "# While loop\n", - "count = 0\n", - "while count < 5:\n", - " print(count)\n", - " count += 1" - ] - }, - { - "cell_type": "markdown", - "id": "41764016-a544-4c9f-a6cf-95b6ef94048d", - "metadata": {}, - "source": [ - "## 3. **Funktionen** **_Functions_**\n", - "\n", - "- Eingeleitet durch das Schlüsselword `def`\n", - "- Name gefolgt von runden Klammern `()`\n", - " - Klammern enthalten Parameter\n", - " - Standard Wert kann angegeben werden\n", - "- Aufruf erfolgt über Name mit runden Klammern\n", - " - Parmeter werden in Klammer übergeben\n", - "\n", - ">>>\n", - "\n", - "- _Introduced by the keyword `def`_\n", - "- _Name followed by round brackets `()`_\n", - " - _Parentheses contain parameters_\n", - " - _Default value can be specified_\n", - "- _Call is made via name with round brackets_\n", - " - _Parameters are passed in brackets_" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "id": "42669de9-c27b-48e4-adae-d98af5f1ddc4", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello, World!\n", - "Hello, Alice!\n" - ] - } - ], - "source": [ - "def greet(name = \"World\"):\n", - " return f\"Hello, {name}!\"\n", - "\n", - "# Nutzt den Standardwert (Use default value)\n", - "print(greet())\n", - "\n", - "# Nutzt eigenen Wert (Use custom value)\n", - "print(greet(name=\"Alice\"))" - ] - }, - { - "cell_type": "markdown", - "id": "b491c200-6071-42e6-a00f-556c2994382f", - "metadata": {}, - "source": [ - "## 4. **Objekt-Orientierte Programmierung** **_Object-Oriented Programming_** (OOP) \n", - "\n", - "Python unterstützt OOP Konzepte wie Klassen, Interfaces, Kapselung und Objekte.\n", - "\n", - "_Python supports OOP concepts such as classes, interfaces, encapsulation and objects._" - ] - }, - { - "cell_type": "markdown", - "id": "4b27c36a-0c42-46c9-8ab9-09e8edfa88d7", - "metadata": {}, - "source": [ - "**Interface Klassen**\n", - "- Interface Klassen werden durch ihre Vererbung von `ABC` kenntlich gemacht\n", - "- Abstrakte Methoden durch die Annotation `@abstractmethod` an der Definition\n", - "\n", - "**Interface classes**\n", - "- Interface classes are identified by their inheritance from `ABC`\n", - "- Abstract methods by the annotation `@abstractmethod` at the definition" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "id": "f627ff43-64f9-4f51-b5f8-ca8b7d29ba8f", - "metadata": {}, - "outputs": [], - "source": [ - "from abc import ABC, abstractmethod\n", - "\n", - "class Humanoid(ABC):\n", - " @abstractmethod\n", - " def greet(self):\n", - " pass" - ] - }, - { - "cell_type": "markdown", - "id": "78dd149b-074e-4b9d-9ec7-4206c7063dd7", - "metadata": {}, - "source": [ - "**💡** Interface Klassen können nicht direkt instanziiert werden, da sie abstrakte Methoden enthalten. \n", - "**💡** _Interface classes cannot be instantiated directly as they contain abstract methods._" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "id": "9844c1fb-a4c9-4ecb-a731-6bb12d9387b1", - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "Can't instantiate abstract class Humanoid with abstract method greet", - "output_type": "error", - "traceback": [ - "\u001b[31m---------------------------------------------------------------------------\u001b[39m", - "\u001b[31mTypeError\u001b[39m Traceback (most recent call last)", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[12]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m humanoid = \u001b[43mHumanoid\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", - "\u001b[31mTypeError\u001b[39m: Can't instantiate abstract class Humanoid with abstract method greet" - ] - } - ], - "source": [ - "humanoid = Humanoid()" - ] - }, - { - "cell_type": "markdown", - "id": "65bd44ae-2b78-4ea8-ad92-86036cf017a8", - "metadata": {}, - "source": [ - "**Definieren einer Klasse**\n", - "- Eine Klasse wird durch das Schlüsselword `class` kenntlich gemacht\n", - "- Das Interface welches implementiert wird ist in Klammern hinter dem Namen der Klasse angegeben\n", - "- Eine Instanz der Klasse wird erzeugt durch den Aufruf des Klassennamens gefolgt von Klammern\n", - " - Dieser Aufrauf enthählt als Parameter die Argumente der `__init__` Funktion\n", - "\n", - "**Define a class**\n", - "- A class is identified by the keyword `class`\n", - "- The interface that is implemented is given in brackets after the name of the class\n", - "- An instance of the class is created by calling the class name followed by parentheses\n", - " - This call contains the arguments of the `__init__` function as parameters" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "id": "59075058-21ec-489d-951c-89a7f8d32672", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hi, I am Alice and I am 25 years old.\n" - ] - } - ], - "source": [ - "class Person(Humanoid):\n", - " def __init__(self, name, age):\n", - " self.name = name\n", - " self.age = age\n", - "\n", - " def greet(self):\n", - " return f\"Hi, I am {self.name} and I am {self.age} years old.\"\n", - "\n", - "# Instanz erzeugen (create an instance)\n", - "person1 = Person(\"Alice\", 25)\n", - "\n", - "# Aufruf einer Methode der Klasse (call method from class)\n", - "print(person1.greet())" - ] - }, - { - "cell_type": "markdown", - "id": "e355397c-4a79-4d66-9e1b-36593149f141", - "metadata": {}, - "source": [ - "**Vererbung**\n", - "- Die Klasse von der geerbt werden soll wird wie bei Interface Klassen in Klammern hinter dem Namen angebenen\n", - "- Der Aufruf der Basis Klasse erfolgt über `super()`\n", - "\n", - "**_Inheritance_**\n", - "- _The class to be inherited from is specified in brackets after the name, as with interface classes_\n", - "- _The base class is called via `super()`_" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "id": "b038a5e9-00db-4186-9ac7-f47a2d4ae23c", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hi, I am Bob and I am 20 years old.\n", - "Bob is in grade A.\n" - ] - } - ], - "source": [ - "class Student(Person):\n", - " def __init__(self, name, age, grade):\n", - " super().__init__(name, age)\n", - " self.grade = grade\n", - "\n", - " def show_grade(self):\n", - " return f\"{self.name} is in grade {self.grade}.\"\n", - "\n", - "# Instanz erzeugen (create an instance)\n", - "student1 = Student(\"Bob\", 20, \"A\")\n", - "\n", - "# Aufruf einer Methode der Basis Klasse (call method from base class)\n", - "print(student1.greet())\n", - "\n", - "# Aufruf einer Methode der Klasse (call method from class)\n", - "print(student1.show_grade())" - ] - }, - { - "cell_type": "markdown", - "id": "ed4b9b13-baf8-42c4-b1b4-8d3bcc0fcd4b", - "metadata": {}, - "source": [ - "## 5. **Externe Module** **_External Modules_**\n", - "\n", - "- Nutze `import` um Bibliotheken und eigene Module zu importieren.\n", - "- Anstellen die komplette Bibliothek zu importieren is es besser nrur die benötigten Funktione/Methoden zu importieren\n", - " - Syntax: `from import [, ]`\n", - "- Pfade werden mit einem Punkt getrennt: `your.custom.package`\n", - "\n", - "\n", - ">>>\n", - "\n", - "- Use `import` to import libraries and custom modules.\n", - "- Instead of importing the complete library it is better to import only the required functions/methods\n", - " - Syntax: `from import [, ]`\n", - "- Paths are separated with a dot: `your.custom.package`" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "id": "39c5ca2c-252d-4cd4-8fe0-34e02c4b7bfd", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello World!\n" - ] - } - ], - "source": [ - "from src.greetings import greet\n", - "\n", - "print(greet())" - ] - }, - { - "cell_type": "markdown", - "id": "1d13f7a8-6985-47fb-8fff-7affe037cca6", - "metadata": {}, - "source": [ - "## 6. **Error Handling**\n", - "\n", - "Python bietet Exceptions an um Fehler weiterzugeben und abzufangen.\n", - "\n", - "_Python offers exceptions to pass on and catch errors._" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "id": "62af9ced-c2a6-4e0c-aeff-cd8e3686246d", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Cannot divide by zero!\n", - "Execution complete.\n" - ] - } - ], - "source": [ - "# Block in dem Fehler gefangen werden (block to catch excpetions)\n", - "try:\n", - " result = 10 / 0\n", - "\n", - "# Fängt Fehler ab (catch excpetion)\n", - "except ZeroDivisionError:\n", - " print(\"Cannot divide by zero!\")\n", - "\n", - "# Wird in jedemfall am Ende ausgeführt (always executed at the end)\n", - "finally:\n", - " print(\"Execution complete.\")" - ] - }, - { - "cell_type": "markdown", - "id": "78db5afd-9419-42f7-b9ed-a09ea1fc4372", - "metadata": {}, - "source": [ - "## 7. **Typing**\n", - "\n", - "Obwohl Python keine typisierte Sprache ist, kann man Hinweise (type hints) einbringen, welche es externen Tools wie [mypy](https://www.mypy-lang.org/) erlauben eine statische Typen Püfung zu machen.\n", - "\n", - "_Although Python is not a typed language, you can include type hints that allow external tools like [mypy](https://www.mypy-lang.org/) to do static type checking._" - ] - }, - { - "cell_type": "markdown", - "id": "d5eb7be2-a16d-4fc8-a00d-d4961d8ff409", - "metadata": {}, - "source": [ - "### Builtin Types" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "id": "a9c46be0-41fd-468c-96ee-ebda46d3bb33", - "metadata": {}, - "outputs": [], - "source": [ - "# Einfache Type (simple types)\n", - "x: int = 1\n", - "x: float = 1.0\n", - "x: bool = True\n", - "x: str = \"test\"\n", - "x: bytes = b\"test\"\n", - "\n", - "# Sammlungen (collections and lists)\n", - "x: list[int] = [1]\n", - "x: set[int] = {6, 7}\n", - "x: dict[str, float] = {\"field\": 2.0}\n", - "x: tuple[int, str, float] = (3, \"yes\", 7.5) \n", - "\n", - "# Tuple mit variabler Länge (tuples with variable size)\n", - "x: tuple[int, ...] = (1, 2, 3) \n", - "\n", - "# Verschiedne Typen (Multiple Types)\n", - "x: list[int | str] = [3, 5, \"test\", \"fun\"] \n", - "x: str | None = None" - ] - }, - { - "cell_type": "markdown", - "id": "5c8c8596-c735-4e33-90d5-decaea1b6329", - "metadata": {}, - "source": [ - "Funktionen und Klassen können ebenfalls mit Type Hints versehen werden. \n", - "_Functions and classes can also be provided_" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "id": "f5a0c35f-77db-4ea1-bd91-17fada451994", - "metadata": {}, - "outputs": [], - "source": [ - "# Funktion mit Parametern (function with parameters)\n", - "# Rückgabe der Funktion wird vor dem : angegeben (return type defined before :)\n", - "def plus(num1: int, num2: int) -> int:\n", - " return num1 + num2\n", - "\n", - "class Alien(Humanoid):\n", - " # Typ for self wird nicht angegeben (type for self is omitted)\n", - " def __init__(self, name: str, age: int) -> None:\n", - " self.name = name\n", - " self.age = age\n", - "\n", - " def greet(self) -> None:\n", - " return f\"Hi, I am {self.name} and I am {self.age} years old.\"" - ] - }, - { - "cell_type": "markdown", - "id": "ddb67354-fb56-4e18-9191-d9649c6973ae", - "metadata": {}, - "source": [ - "**[NEXT (Numpy)](numpy_tutorial.ipynb)**" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.11" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/uv.lock b/uv.lock index 102db09..fc95be9 100644 --- a/uv.lock +++ b/uv.lock @@ -422,6 +422,48 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/cf/58/8acf1b3e91c58313ce5cb67df61001fc9dcd21be4fadb76c1a2d540e09ed/fqdn-1.5.1-py3-none-any.whl", hash = "sha256:3a179af3761e4df6eb2e026ff9e1a3033d3587bf980a0b1b2e1e5d08d7358014", size = 9121, upload_time = "2021-03-11T07:16:28.351Z" }, ] +[[package]] +name = "greenlet" +version = "3.2.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/03/b8/704d753a5a45507a7aab61f18db9509302ed3d0a27ac7e0359ec2905b1a6/greenlet-3.2.4.tar.gz", hash = "sha256:0dca0d95ff849f9a364385f36ab49f50065d76964944638be9691e1832e9f86d", size = 188260, upload_time = "2025-08-07T13:24:33.51Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a4/de/f28ced0a67749cac23fecb02b694f6473f47686dff6afaa211d186e2ef9c/greenlet-3.2.4-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:96378df1de302bc38e99c3a9aa311967b7dc80ced1dcc6f171e99842987882a2", size = 272305, upload_time = "2025-08-07T13:15:41.288Z" }, + { url = "https://files.pythonhosted.org/packages/09/16/2c3792cba130000bf2a31c5272999113f4764fd9d874fb257ff588ac779a/greenlet-3.2.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:1ee8fae0519a337f2329cb78bd7a8e128ec0f881073d43f023c7b8d4831d5246", size = 632472, upload_time = "2025-08-07T13:42:55.044Z" }, + { url = "https://files.pythonhosted.org/packages/ae/8f/95d48d7e3d433e6dae5b1682e4292242a53f22df82e6d3dda81b1701a960/greenlet-3.2.4-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:94abf90142c2a18151632371140b3dba4dee031633fe614cb592dbb6c9e17bc3", size = 644646, upload_time = "2025-08-07T13:45:26.523Z" }, + { url = "https://files.pythonhosted.org/packages/d5/5e/405965351aef8c76b8ef7ad370e5da58d57ef6068df197548b015464001a/greenlet-3.2.4-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:4d1378601b85e2e5171b99be8d2dc85f594c79967599328f95c1dc1a40f1c633", size = 640519, upload_time = "2025-08-07T13:53:13.928Z" }, + { url = "https://files.pythonhosted.org/packages/25/5d/382753b52006ce0218297ec1b628e048c4e64b155379331f25a7316eb749/greenlet-3.2.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:0db5594dce18db94f7d1650d7489909b57afde4c580806b8d9203b6e79cdc079", size = 639707, upload_time = "2025-08-07T13:18:27.146Z" }, + { url = "https://files.pythonhosted.org/packages/1f/8e/abdd3f14d735b2929290a018ecf133c901be4874b858dd1c604b9319f064/greenlet-3.2.4-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2523e5246274f54fdadbce8494458a2ebdcdbc7b802318466ac5606d3cded1f8", size = 587684, upload_time = "2025-08-07T13:18:25.164Z" }, + { url = "https://files.pythonhosted.org/packages/5d/65/deb2a69c3e5996439b0176f6651e0052542bb6c8f8ec2e3fba97c9768805/greenlet-3.2.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:1987de92fec508535687fb807a5cea1560f6196285a4cde35c100b8cd632cc52", size = 1116647, upload_time = "2025-08-07T13:42:38.655Z" }, + { url = "https://files.pythonhosted.org/packages/3f/cc/b07000438a29ac5cfb2194bfc128151d52f333cee74dd7dfe3fb733fc16c/greenlet-3.2.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:55e9c5affaa6775e2c6b67659f3a71684de4c549b3dd9afca3bc773533d284fa", size = 1142073, upload_time = "2025-08-07T13:18:21.737Z" }, + { url = "https://files.pythonhosted.org/packages/d8/0f/30aef242fcab550b0b3520b8e3561156857c94288f0332a79928c31a52cf/greenlet-3.2.4-cp311-cp311-win_amd64.whl", hash = "sha256:9c40adce87eaa9ddb593ccb0fa6a07caf34015a29bf8d344811665b573138db9", size = 299100, upload_time = "2025-08-07T13:44:12.287Z" }, + { url = "https://files.pythonhosted.org/packages/44/69/9b804adb5fd0671f367781560eb5eb586c4d495277c93bde4307b9e28068/greenlet-3.2.4-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:3b67ca49f54cede0186854a008109d6ee71f66bd57bb36abd6d0a0267b540cdd", size = 274079, upload_time = "2025-08-07T13:15:45.033Z" }, + { url = "https://files.pythonhosted.org/packages/46/e9/d2a80c99f19a153eff70bc451ab78615583b8dac0754cfb942223d2c1a0d/greenlet-3.2.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:ddf9164e7a5b08e9d22511526865780a576f19ddd00d62f8a665949327fde8bb", size = 640997, upload_time = "2025-08-07T13:42:56.234Z" }, + { url = "https://files.pythonhosted.org/packages/3b/16/035dcfcc48715ccd345f3a93183267167cdd162ad123cd93067d86f27ce4/greenlet-3.2.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:f28588772bb5fb869a8eb331374ec06f24a83a9c25bfa1f38b6993afe9c1e968", size = 655185, upload_time = "2025-08-07T13:45:27.624Z" }, + { url = "https://files.pythonhosted.org/packages/31/da/0386695eef69ffae1ad726881571dfe28b41970173947e7c558d9998de0f/greenlet-3.2.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:5c9320971821a7cb77cfab8d956fa8e39cd07ca44b6070db358ceb7f8797c8c9", size = 649926, upload_time = "2025-08-07T13:53:15.251Z" }, + { url = "https://files.pythonhosted.org/packages/68/88/69bf19fd4dc19981928ceacbc5fd4bb6bc2215d53199e367832e98d1d8fe/greenlet-3.2.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c60a6d84229b271d44b70fb6e5fa23781abb5d742af7b808ae3f6efd7c9c60f6", size = 651839, upload_time = "2025-08-07T13:18:30.281Z" }, + { url = "https://files.pythonhosted.org/packages/19/0d/6660d55f7373b2ff8152401a83e02084956da23ae58cddbfb0b330978fe9/greenlet-3.2.4-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3b3812d8d0c9579967815af437d96623f45c0f2ae5f04e366de62a12d83a8fb0", size = 607586, upload_time = "2025-08-07T13:18:28.544Z" }, + { url = "https://files.pythonhosted.org/packages/8e/1a/c953fdedd22d81ee4629afbb38d2f9d71e37d23caace44775a3a969147d4/greenlet-3.2.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:abbf57b5a870d30c4675928c37278493044d7c14378350b3aa5d484fa65575f0", size = 1123281, upload_time = "2025-08-07T13:42:39.858Z" }, + { url = "https://files.pythonhosted.org/packages/3f/c7/12381b18e21aef2c6bd3a636da1088b888b97b7a0362fac2e4de92405f97/greenlet-3.2.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:20fb936b4652b6e307b8f347665e2c615540d4b42b3b4c8a321d8286da7e520f", size = 1151142, upload_time = "2025-08-07T13:18:22.981Z" }, + { url = "https://files.pythonhosted.org/packages/e9/08/b0814846b79399e585f974bbeebf5580fbe59e258ea7be64d9dfb253c84f/greenlet-3.2.4-cp312-cp312-win_amd64.whl", hash = "sha256:a7d4e128405eea3814a12cc2605e0e6aedb4035bf32697f72deca74de4105e02", size = 299899, upload_time = "2025-08-07T13:38:53.448Z" }, + { url = "https://files.pythonhosted.org/packages/49/e8/58c7f85958bda41dafea50497cbd59738c5c43dbbea5ee83d651234398f4/greenlet-3.2.4-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:1a921e542453fe531144e91e1feedf12e07351b1cf6c9e8a3325ea600a715a31", size = 272814, upload_time = "2025-08-07T13:15:50.011Z" }, + { url = "https://files.pythonhosted.org/packages/62/dd/b9f59862e9e257a16e4e610480cfffd29e3fae018a68c2332090b53aac3d/greenlet-3.2.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:cd3c8e693bff0fff6ba55f140bf390fa92c994083f838fece0f63be121334945", size = 641073, upload_time = "2025-08-07T13:42:57.23Z" }, + { url = "https://files.pythonhosted.org/packages/f7/0b/bc13f787394920b23073ca3b6c4a7a21396301ed75a655bcb47196b50e6e/greenlet-3.2.4-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:710638eb93b1fa52823aa91bf75326f9ecdfd5e0466f00789246a5280f4ba0fc", size = 655191, upload_time = "2025-08-07T13:45:29.752Z" }, + { url = "https://files.pythonhosted.org/packages/f2/d6/6adde57d1345a8d0f14d31e4ab9c23cfe8e2cd39c3baf7674b4b0338d266/greenlet-3.2.4-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:c5111ccdc9c88f423426df3fd1811bfc40ed66264d35aa373420a34377efc98a", size = 649516, upload_time = "2025-08-07T13:53:16.314Z" }, + { url = "https://files.pythonhosted.org/packages/7f/3b/3a3328a788d4a473889a2d403199932be55b1b0060f4ddd96ee7cdfcad10/greenlet-3.2.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:d76383238584e9711e20ebe14db6c88ddcedc1829a9ad31a584389463b5aa504", size = 652169, upload_time = "2025-08-07T13:18:32.861Z" }, + { url = "https://files.pythonhosted.org/packages/ee/43/3cecdc0349359e1a527cbf2e3e28e5f8f06d3343aaf82ca13437a9aa290f/greenlet-3.2.4-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:23768528f2911bcd7e475210822ffb5254ed10d71f4028387e5a99b4c6699671", size = 610497, upload_time = "2025-08-07T13:18:31.636Z" }, + { url = "https://files.pythonhosted.org/packages/b8/19/06b6cf5d604e2c382a6f31cafafd6f33d5dea706f4db7bdab184bad2b21d/greenlet-3.2.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:00fadb3fedccc447f517ee0d3fd8fe49eae949e1cd0f6a611818f4f6fb7dc83b", size = 1121662, upload_time = "2025-08-07T13:42:41.117Z" }, + { url = "https://files.pythonhosted.org/packages/a2/15/0d5e4e1a66fab130d98168fe984c509249c833c1a3c16806b90f253ce7b9/greenlet-3.2.4-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:d25c5091190f2dc0eaa3f950252122edbbadbb682aa7b1ef2f8af0f8c0afefae", size = 1149210, upload_time = "2025-08-07T13:18:24.072Z" }, + { url = "https://files.pythonhosted.org/packages/0b/55/2321e43595e6801e105fcfdee02b34c0f996eb71e6ddffca6b10b7e1d771/greenlet-3.2.4-cp313-cp313-win_amd64.whl", hash = "sha256:554b03b6e73aaabec3745364d6239e9e012d64c68ccd0b8430c64ccc14939a8b", size = 299685, upload_time = "2025-08-07T13:24:38.824Z" }, + { url = "https://files.pythonhosted.org/packages/22/5c/85273fd7cc388285632b0498dbbab97596e04b154933dfe0f3e68156c68c/greenlet-3.2.4-cp314-cp314-macosx_11_0_universal2.whl", hash = "sha256:49a30d5fda2507ae77be16479bdb62a660fa51b1eb4928b524975b3bde77b3c0", size = 273586, upload_time = "2025-08-07T13:16:08.004Z" }, + { url = "https://files.pythonhosted.org/packages/d1/75/10aeeaa3da9332c2e761e4c50d4c3556c21113ee3f0afa2cf5769946f7a3/greenlet-3.2.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:299fd615cd8fc86267b47597123e3f43ad79c9d8a22bebdce535e53550763e2f", size = 686346, upload_time = "2025-08-07T13:42:59.944Z" }, + { url = "https://files.pythonhosted.org/packages/c0/aa/687d6b12ffb505a4447567d1f3abea23bd20e73a5bed63871178e0831b7a/greenlet-3.2.4-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:c17b6b34111ea72fc5a4e4beec9711d2226285f0386ea83477cbb97c30a3f3a5", size = 699218, upload_time = "2025-08-07T13:45:30.969Z" }, + { url = "https://files.pythonhosted.org/packages/dc/8b/29aae55436521f1d6f8ff4e12fb676f3400de7fcf27fccd1d4d17fd8fecd/greenlet-3.2.4-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b4a1870c51720687af7fa3e7cda6d08d801dae660f75a76f3845b642b4da6ee1", size = 694659, upload_time = "2025-08-07T13:53:17.759Z" }, + { url = "https://files.pythonhosted.org/packages/92/2e/ea25914b1ebfde93b6fc4ff46d6864564fba59024e928bdc7de475affc25/greenlet-3.2.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:061dc4cf2c34852b052a8620d40f36324554bc192be474b9e9770e8c042fd735", size = 695355, upload_time = "2025-08-07T13:18:34.517Z" }, + { url = "https://files.pythonhosted.org/packages/72/60/fc56c62046ec17f6b0d3060564562c64c862948c9d4bc8aa807cf5bd74f4/greenlet-3.2.4-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:44358b9bf66c8576a9f57a590d5f5d6e72fa4228b763d0e43fee6d3b06d3a337", size = 657512, upload_time = "2025-08-07T13:18:33.969Z" }, + { url = "https://files.pythonhosted.org/packages/e3/a5/6ddab2b4c112be95601c13428db1d8b6608a8b6039816f2ba09c346c08fc/greenlet-3.2.4-cp314-cp314-win_amd64.whl", hash = "sha256:e37ab26028f12dbb0ff65f29a8d3d44a765c61e729647bf2ddfbbed621726f01", size = 303425, upload_time = "2025-08-07T13:32:27.59Z" }, +] + [[package]] name = "h11" version = "0.16.0" @@ -1074,6 +1116,44 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/36/56/947abc9885841744c708d57871c05d381ecb1bb8f12e5d6ec138e4cf99e6/mpl_interactions-0.24.2-py3-none-any.whl", hash = "sha256:bacda7af49007096942d01a4973e7df5b52afaa8385a688a383e34ffee6105d3", size = 45549, upload_time = "2024-09-10T20:45:10.142Z" }, ] +[[package]] +name = "msgpack" +version = "1.1.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/45/b1/ea4f68038a18c77c9467400d166d74c4ffa536f34761f7983a104357e614/msgpack-1.1.1.tar.gz", hash = "sha256:77b79ce34a2bdab2594f490c8e80dd62a02d650b91a75159a63ec413b8d104cd", size = 173555, upload_time = "2025-06-13T06:52:51.324Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7f/83/97f24bf9848af23fe2ba04380388216defc49a8af6da0c28cc636d722502/msgpack-1.1.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:71ef05c1726884e44f8b1d1773604ab5d4d17729d8491403a705e649116c9558", size = 82728, upload_time = "2025-06-13T06:51:50.68Z" }, + { url = "https://files.pythonhosted.org/packages/aa/7f/2eaa388267a78401f6e182662b08a588ef4f3de6f0eab1ec09736a7aaa2b/msgpack-1.1.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:36043272c6aede309d29d56851f8841ba907a1a3d04435e43e8a19928e243c1d", size = 79279, upload_time = "2025-06-13T06:51:51.72Z" }, + { url = "https://files.pythonhosted.org/packages/f8/46/31eb60f4452c96161e4dfd26dbca562b4ec68c72e4ad07d9566d7ea35e8a/msgpack-1.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a32747b1b39c3ac27d0670122b57e6e57f28eefb725e0b625618d1b59bf9d1e0", size = 423859, upload_time = "2025-06-13T06:51:52.749Z" }, + { url = "https://files.pythonhosted.org/packages/45/16/a20fa8c32825cc7ae8457fab45670c7a8996d7746ce80ce41cc51e3b2bd7/msgpack-1.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8a8b10fdb84a43e50d38057b06901ec9da52baac6983d3f709d8507f3889d43f", size = 429975, upload_time = "2025-06-13T06:51:53.97Z" }, + { url = "https://files.pythonhosted.org/packages/86/ea/6c958e07692367feeb1a1594d35e22b62f7f476f3c568b002a5ea09d443d/msgpack-1.1.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ba0c325c3f485dc54ec298d8b024e134acf07c10d494ffa24373bea729acf704", size = 413528, upload_time = "2025-06-13T06:51:55.507Z" }, + { url = "https://files.pythonhosted.org/packages/75/05/ac84063c5dae79722bda9f68b878dc31fc3059adb8633c79f1e82c2cd946/msgpack-1.1.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:88daaf7d146e48ec71212ce21109b66e06a98e5e44dca47d853cbfe171d6c8d2", size = 413338, upload_time = "2025-06-13T06:51:57.023Z" }, + { url = "https://files.pythonhosted.org/packages/69/e8/fe86b082c781d3e1c09ca0f4dacd457ede60a13119b6ce939efe2ea77b76/msgpack-1.1.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:d8b55ea20dc59b181d3f47103f113e6f28a5e1c89fd5b67b9140edb442ab67f2", size = 422658, upload_time = "2025-06-13T06:51:58.419Z" }, + { url = "https://files.pythonhosted.org/packages/3b/2b/bafc9924df52d8f3bb7c00d24e57be477f4d0f967c0a31ef5e2225e035c7/msgpack-1.1.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:4a28e8072ae9779f20427af07f53bbb8b4aa81151054e882aee333b158da8752", size = 427124, upload_time = "2025-06-13T06:51:59.969Z" }, + { url = "https://files.pythonhosted.org/packages/a2/3b/1f717e17e53e0ed0b68fa59e9188f3f610c79d7151f0e52ff3cd8eb6b2dc/msgpack-1.1.1-cp311-cp311-win32.whl", hash = "sha256:7da8831f9a0fdb526621ba09a281fadc58ea12701bc709e7b8cbc362feabc295", size = 65016, upload_time = "2025-06-13T06:52:01.294Z" }, + { url = "https://files.pythonhosted.org/packages/48/45/9d1780768d3b249accecc5a38c725eb1e203d44a191f7b7ff1941f7df60c/msgpack-1.1.1-cp311-cp311-win_amd64.whl", hash = "sha256:5fd1b58e1431008a57247d6e7cc4faa41c3607e8e7d4aaf81f7c29ea013cb458", size = 72267, upload_time = "2025-06-13T06:52:02.568Z" }, + { url = "https://files.pythonhosted.org/packages/e3/26/389b9c593eda2b8551b2e7126ad3a06af6f9b44274eb3a4f054d48ff7e47/msgpack-1.1.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:ae497b11f4c21558d95de9f64fff7053544f4d1a17731c866143ed6bb4591238", size = 82359, upload_time = "2025-06-13T06:52:03.909Z" }, + { url = "https://files.pythonhosted.org/packages/ab/65/7d1de38c8a22cf8b1551469159d4b6cf49be2126adc2482de50976084d78/msgpack-1.1.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:33be9ab121df9b6b461ff91baac6f2731f83d9b27ed948c5b9d1978ae28bf157", size = 79172, upload_time = "2025-06-13T06:52:05.246Z" }, + { url = "https://files.pythonhosted.org/packages/0f/bd/cacf208b64d9577a62c74b677e1ada005caa9b69a05a599889d6fc2ab20a/msgpack-1.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6f64ae8fe7ffba251fecb8408540c34ee9df1c26674c50c4544d72dbf792e5ce", size = 425013, upload_time = "2025-06-13T06:52:06.341Z" }, + { url = "https://files.pythonhosted.org/packages/4d/ec/fd869e2567cc9c01278a736cfd1697941ba0d4b81a43e0aa2e8d71dab208/msgpack-1.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a494554874691720ba5891c9b0b39474ba43ffb1aaf32a5dac874effb1619e1a", size = 426905, upload_time = "2025-06-13T06:52:07.501Z" }, + { url = "https://files.pythonhosted.org/packages/55/2a/35860f33229075bce803a5593d046d8b489d7ba2fc85701e714fc1aaf898/msgpack-1.1.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cb643284ab0ed26f6957d969fe0dd8bb17beb567beb8998140b5e38a90974f6c", size = 407336, upload_time = "2025-06-13T06:52:09.047Z" }, + { url = "https://files.pythonhosted.org/packages/8c/16/69ed8f3ada150bf92745fb4921bd621fd2cdf5a42e25eb50bcc57a5328f0/msgpack-1.1.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:d275a9e3c81b1093c060c3837e580c37f47c51eca031f7b5fb76f7b8470f5f9b", size = 409485, upload_time = "2025-06-13T06:52:10.382Z" }, + { url = "https://files.pythonhosted.org/packages/c6/b6/0c398039e4c6d0b2e37c61d7e0e9d13439f91f780686deb8ee64ecf1ae71/msgpack-1.1.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:4fd6b577e4541676e0cc9ddc1709d25014d3ad9a66caa19962c4f5de30fc09ef", size = 412182, upload_time = "2025-06-13T06:52:11.644Z" }, + { url = "https://files.pythonhosted.org/packages/b8/d0/0cf4a6ecb9bc960d624c93effaeaae75cbf00b3bc4a54f35c8507273cda1/msgpack-1.1.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:bb29aaa613c0a1c40d1af111abf025f1732cab333f96f285d6a93b934738a68a", size = 419883, upload_time = "2025-06-13T06:52:12.806Z" }, + { url = "https://files.pythonhosted.org/packages/62/83/9697c211720fa71a2dfb632cad6196a8af3abea56eece220fde4674dc44b/msgpack-1.1.1-cp312-cp312-win32.whl", hash = "sha256:870b9a626280c86cff9c576ec0d9cbcc54a1e5ebda9cd26dab12baf41fee218c", size = 65406, upload_time = "2025-06-13T06:52:14.271Z" }, + { url = "https://files.pythonhosted.org/packages/c0/23/0abb886e80eab08f5e8c485d6f13924028602829f63b8f5fa25a06636628/msgpack-1.1.1-cp312-cp312-win_amd64.whl", hash = "sha256:5692095123007180dca3e788bb4c399cc26626da51629a31d40207cb262e67f4", size = 72558, upload_time = "2025-06-13T06:52:15.252Z" }, + { url = "https://files.pythonhosted.org/packages/a1/38/561f01cf3577430b59b340b51329803d3a5bf6a45864a55f4ef308ac11e3/msgpack-1.1.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:3765afa6bd4832fc11c3749be4ba4b69a0e8d7b728f78e68120a157a4c5d41f0", size = 81677, upload_time = "2025-06-13T06:52:16.64Z" }, + { url = "https://files.pythonhosted.org/packages/09/48/54a89579ea36b6ae0ee001cba8c61f776451fad3c9306cd80f5b5c55be87/msgpack-1.1.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:8ddb2bcfd1a8b9e431c8d6f4f7db0773084e107730ecf3472f1dfe9ad583f3d9", size = 78603, upload_time = "2025-06-13T06:52:17.843Z" }, + { url = "https://files.pythonhosted.org/packages/a0/60/daba2699b308e95ae792cdc2ef092a38eb5ee422f9d2fbd4101526d8a210/msgpack-1.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:196a736f0526a03653d829d7d4c5500a97eea3648aebfd4b6743875f28aa2af8", size = 420504, upload_time = "2025-06-13T06:52:18.982Z" }, + { url = "https://files.pythonhosted.org/packages/20/22/2ebae7ae43cd8f2debc35c631172ddf14e2a87ffcc04cf43ff9df9fff0d3/msgpack-1.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9d592d06e3cc2f537ceeeb23d38799c6ad83255289bb84c2e5792e5a8dea268a", size = 423749, upload_time = "2025-06-13T06:52:20.211Z" }, + { url = "https://files.pythonhosted.org/packages/40/1b/54c08dd5452427e1179a40b4b607e37e2664bca1c790c60c442c8e972e47/msgpack-1.1.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4df2311b0ce24f06ba253fda361f938dfecd7b961576f9be3f3fbd60e87130ac", size = 404458, upload_time = "2025-06-13T06:52:21.429Z" }, + { url = "https://files.pythonhosted.org/packages/2e/60/6bb17e9ffb080616a51f09928fdd5cac1353c9becc6c4a8abd4e57269a16/msgpack-1.1.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:e4141c5a32b5e37905b5940aacbc59739f036930367d7acce7a64e4dec1f5e0b", size = 405976, upload_time = "2025-06-13T06:52:22.995Z" }, + { url = "https://files.pythonhosted.org/packages/ee/97/88983e266572e8707c1f4b99c8fd04f9eb97b43f2db40e3172d87d8642db/msgpack-1.1.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:b1ce7f41670c5a69e1389420436f41385b1aa2504c3b0c30620764b15dded2e7", size = 408607, upload_time = "2025-06-13T06:52:24.152Z" }, + { url = "https://files.pythonhosted.org/packages/bc/66/36c78af2efaffcc15a5a61ae0df53a1d025f2680122e2a9eb8442fed3ae4/msgpack-1.1.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4147151acabb9caed4e474c3344181e91ff7a388b888f1e19ea04f7e73dc7ad5", size = 424172, upload_time = "2025-06-13T06:52:25.704Z" }, + { url = "https://files.pythonhosted.org/packages/8c/87/a75eb622b555708fe0427fab96056d39d4c9892b0c784b3a721088c7ee37/msgpack-1.1.1-cp313-cp313-win32.whl", hash = "sha256:500e85823a27d6d9bba1d057c871b4210c1dd6fb01fbb764e37e4e8847376323", size = 65347, upload_time = "2025-06-13T06:52:26.846Z" }, + { url = "https://files.pythonhosted.org/packages/ca/91/7dc28d5e2a11a5ad804cf2b7f7a5fcb1eb5a4966d66a5d2b41aee6376543/msgpack-1.1.1-cp313-cp313-win_amd64.whl", hash = "sha256:6d489fba546295983abd142812bda76b57e33d0b9f5d5b71c09a583285506f69", size = 72341, upload_time = "2025-06-13T06:52:27.835Z" }, +] + [[package]] name = "nbclient" version = "0.10.2" @@ -1411,6 +1491,20 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/8a/0b/9fcc47d19c48b59121088dd6da2488a49d5f72dacf8262e2790a1d2c7d15/pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c", size = 1225293, upload_time = "2025-01-06T17:26:25.553Z" }, ] +[[package]] +name = "pynvim" +version = "0.5.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "greenlet", marker = "platform_python_implementation != 'PyPy'" }, + { name = "msgpack" }, + { name = "typing-extensions", marker = "python_full_version < '3.12'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/09/84/c77ec45e084907e128710e08f5d7926723d7a67ccbebf27089309118807d/pynvim-0.5.2.tar.gz", hash = "sha256:734a2432db8683519f58572617528ecb4a2f321bc7b27f034b3f9b2322c15615", size = 50053, upload_time = "2024-11-13T03:07:08.734Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d2/11/70758ae8d5869241fe5f6ae2083a9af908f037d07e847bec53de0f96c51b/pynvim-0.5.2-py3-none-any.whl", hash = "sha256:20b1c5a18c4cddfc480950094d4135f782b1a98c32149ea63e24bbdb7021eb54", size = 46175, upload_time = "2024-11-13T03:07:07.64Z" }, +] + [[package]] name = "pyparsing" version = "3.2.3" @@ -1447,6 +1541,53 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b2/05/77b60e520511c53d1c1ca75f1930c7dd8e971d0c4379b7f4b3f9644685ba/pytest_mock-3.14.1-py3-none-any.whl", hash = "sha256:178aefcd11307d874b4cd3100344e7e2d888d9791a6a1d9bfe90fbc1b74fd1d0", size = 9923, upload_time = "2025-05-26T13:58:43.487Z" }, ] +[[package]] +name = "python-basic-tutorial" +version = "0.1.0" +source = { virtual = "." } +dependencies = [ + { name = "ipympl" }, + { name = "ipytest" }, + { name = "jupyterlab-language-pack-de-de" }, + { name = "matplotlib" }, + { name = "mpl-interactions" }, + { name = "numpy" }, + { name = "pillow" }, + { name = "pytest" }, + { name = "pytest-mock" }, + { name = "pyyaml" }, +] + +[package.dev-dependencies] +dev = [ + { name = "ipykernel" }, + { name = "pynvim" }, +] +local = [ + { name = "jupyter" }, +] + +[package.metadata] +requires-dist = [ + { name = "ipympl", specifier = ">=0.9.7" }, + { name = "ipytest", specifier = ">=0.14.2" }, + { name = "jupyterlab-language-pack-de-de", specifier = ">=4.4.post0" }, + { name = "matplotlib", specifier = ">=3.10.3" }, + { name = "mpl-interactions", specifier = ">=0.24.2" }, + { name = "numpy", specifier = ">=2.2.6" }, + { name = "pillow", specifier = ">=11.2.1" }, + { name = "pytest", specifier = ">=8.3.5" }, + { name = "pytest-mock", specifier = ">=3.14.1" }, + { name = "pyyaml", specifier = ">=6.0.2" }, +] + +[package.metadata.requires-dev] +dev = [ + { name = "ipykernel", specifier = ">=6.29.5" }, + { name = "pynvim", specifier = ">=0.5.2" }, +] +local = [{ name = "jupyter", specifier = ">=1.1.1" }] + [[package]] name = "python-dateutil" version = "2.9.0.post0" @@ -1782,45 +1923,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/6a/9e/2064975477fdc887e47ad42157e214526dcad8f317a948dee17e1659a62f/terminado-0.18.1-py3-none-any.whl", hash = "sha256:a4468e1b37bb318f8a86514f65814e1afc977cf29b3992a4500d9dd305dcceb0", size = 14154, upload_time = "2024-03-12T14:34:36.569Z" }, ] -[[package]] -name = "test-binder" -version = "0.1.0" -source = { virtual = "." } -dependencies = [ - { name = "ipympl" }, - { name = "ipytest" }, - { name = "jupyterlab-language-pack-de-de" }, - { name = "matplotlib" }, - { name = "mpl-interactions" }, - { name = "numpy" }, - { name = "pillow" }, - { name = "pytest" }, - { name = "pytest-mock" }, - { name = "pyyaml" }, -] - -[package.dev-dependencies] -local = [ - { name = "jupyter" }, -] - -[package.metadata] -requires-dist = [ - { name = "ipympl", specifier = ">=0.9.7" }, - { name = "ipytest", specifier = ">=0.14.2" }, - { name = "jupyterlab-language-pack-de-de", specifier = ">=4.4.post0" }, - { name = "matplotlib", specifier = ">=3.10.3" }, - { name = "mpl-interactions", specifier = ">=0.24.2" }, - { name = "numpy", specifier = ">=2.2.6" }, - { name = "pillow", specifier = ">=11.2.1" }, - { name = "pytest", specifier = ">=8.3.5" }, - { name = "pytest-mock", specifier = ">=3.14.1" }, - { name = "pyyaml", specifier = ">=6.0.2" }, -] - -[package.metadata.requires-dev] -local = [{ name = "jupyter", specifier = ">=1.1.1" }] - [[package]] name = "tinycss2" version = "1.4.0"