{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "845e4ce0-43b9-4899-bdc0-19a9fd288890",
   "metadata": {},
   "source": [
    "# Notizen 2026-06-29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "cb780445-c934-4375-98fa-f41a89c47fcf",
   "metadata": {},
   "outputs": [],
   "source": [
    "g3 = {'Anna': {'jahr': '2005', 'monat': '02', 'tag': '10'},\n",
    " 'Ben': {'jahr': '2004', 'monat': '02', 'tag': '23'},\n",
    " 'Charly': {'jahr': '2005', 'monat': '02', 'tag': '10'}}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "e1978d19-08a4-4d7c-87df-ee70147770c9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "zeile 5: Person='Anna',  Geburtstag_dict={'jahr': '2005', 'monat': '02', 'tag': '10'}, Person='Anna', jahr='2005'\n",
      "zeile 5: Person='Ben',  Geburtstag_dict={'jahr': '2004', 'monat': '02', 'tag': '23'}, Person='Ben', jahr='2004'\n",
      "zeile 5: Person='Charly',  Geburtstag_dict={'jahr': '2005', 'monat': '02', 'tag': '10'}, Person='Charly', jahr='2005'\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'2005': {'Anna', 'Charly'}, '2004': {'Ben'}}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ergebnis = {}\n",
    "\n",
    "for Person, Geburtstag_dict in g3.items():\n",
    "    jahr = Geburtstag_dict['jahr']\n",
    "    print( f\"zeile 5: {Person=}, { Geburtstag_dict=}, {Person=}, {jahr=}\")\n",
    "\n",
    "    if jahr not in ergebnis:\n",
    "        ergebnis[jahr] = set()\n",
    "    \n",
    "    ergebnis[jahr].add(Person)\n",
    "    \n",
    "ergebnis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "5008882d-5161-4764-8fe1-d62bd5fee65a",
   "metadata": {},
   "outputs": [],
   "source": [
    "l1 = [\"jjjj\", \"mm\", \"tt\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "67700012-b0f7-407b-a055-82cdff7289cf",
   "metadata": {},
   "outputs": [],
   "source": [
    "l2 = ['2005', '02', '10']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "c5b86bbe-531f-4225-b643-459c7dfd4fa0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'jjjj': '2005', 'mm': '02', 'tt': '10'}"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict( zip( l1, l2 ) )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "ad4893f1-b5c2-4437-86bd-c0d3d25d3cc6",
   "metadata": {},
   "outputs": [],
   "source": [
    "g2 = {'Anna': ['2005', '02', '10'], 'Ben': ['2004', '02', '23'], 'Charly': ['2005', '02', '10']}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "e865e95c-c0c3-4b2a-aa76-d0c5c6f09a03",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "schluessel = [\"jjjj\", \"mm\", \"tt\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "0fd6ea7b-bd96-470b-9289-17e2e6092df7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Anna': {'jjjj': '2005', 'mm': '02', 'tt': '10'},\n",
       " 'Ben': {'jjjj': '2004', 'mm': '02', 'tt': '23'},\n",
       " 'Charly': {'jjjj': '2005', 'mm': '02', 'tt': '10'}}"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ergbnis = {}\n",
    "\n",
    "for Person, GebDatumListe in g2.items():\n",
    "    ergbnis[Person] = dict(zip(schluessel, GebDatumListe))\n",
    "\n",
    "ergbnis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "68c8c9b6-bbb2-4454-9ec6-71efa4dde2e7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Anna': {'jjjj': '2005', 'mm': '02', 'tt': '10'},\n",
       " 'Ben': {'jjjj': '2004', 'mm': '02', 'tt': '23'},\n",
       " 'Charly': {'jjjj': '2005', 'mm': '02', 'tt': '10'}}"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ergbnis = {   Person:  dict(zip(schluessel, GebDatumListe))   for Person, GebDatumListe in g2.items()       }\n",
    "ergbnis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "275df862-c52b-4248-8f03-cde426b240b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Anna': {'jjjj': '2005', 'mm': '02', 'tt': '10'},\n",
       " 'Ben': {'jjjj': '2004', 'mm': '02', 'tt': '23'},\n",
       " 'Charly': {'jjjj': '2005', 'mm': '02', 'tt': '10'}}"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ergbnis = {   Person: {\"jjjj\": j, \"mm\": m, \"tt\":t }  for Person, [j,m,t] in g2.items()       }\n",
    "ergbnis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "50d7350b-46d0-4242-927d-7664738b1cef",
   "metadata": {},
   "outputs": [],
   "source": [
    "g = { \"Anna\": \"2005-02-10\", \"Ben\": \"2004-02-23\", \"Charly\": \"2005-02-10\" }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "c39ae265-a4f5-4f5e-b286-8f8d5bfe47e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Anna': ['2005', '02', '10'],\n",
       " 'Ben': ['2004', '02', '23'],\n",
       " 'Charly': ['2005', '02', '10']}"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e = {  k: v.split(\"-\")    for   k, v in  g.items()  }    \n",
    "e"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "91c5bdbf-2469-44ec-b0ce-a4908a3718d5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "014a182d-e6b0-42f5-82f3-832609f722c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "gedicht = \"\"\"\n",
    "Klarer Code fließt sanft,\n",
    "Python wird zu Poesie.\n",
    "\n",
    "Einfach, schön.\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "3e779b09-f194-4741-8a32-eca69f2ae7ad",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['',\n",
       " 'Klarer Code fließt sanft,',\n",
       " 'Python wird zu Poesie.',\n",
       " '',\n",
       " 'Einfach, schön.']"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gedicht.splitlines()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "520a79d4-51d8-4cff-95de-71cbbc2257a1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Klarer Code fließt sanft,', 'Python wird zu Poesie.', 'Einfach, schön.']"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[ zeile for zeile in gedicht.splitlines()   if len(zeile) > 0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "9028c966-c766-45c3-865c-ad7f1e350f23",
   "metadata": {},
   "outputs": [],
   "source": [
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "31e700d2-8f43-4962-820c-5a82a304ca91",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function split in module re:\n",
      "\n",
      "split(pattern, string, maxsplit=0, flags=0)\n",
      "    Split the source string by the occurrences of the pattern,\n",
      "    returning a list containing the resulting substrings.  If\n",
      "    capturing parentheses are used in pattern, then the text of all\n",
      "    groups in the pattern are also returned as part of the resulting\n",
      "    list.  If maxsplit is nonzero, at most maxsplit splits occur,\n",
      "    and the remainder of the string is returned as the final element\n",
      "    of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help( re.split )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "9a007c39-ce01-44f1-9919-48b7f176afa0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len( [ x for x in re.split( r\"\\s\", gedicht)if len(x) > 0 ] )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8b09dca1-8cc4-40c2-a80c-d64d32433a04",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "750ffcb5-a576-4d83-a0a3-ba86a3b0dbd4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum( [ len( zeile.split()) for zeile in gedicht.splitlines()   if len(zeile) > 0] )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "78e148de-9fcf-46a9-a448-20f2928ca6f9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Klarer Code fließt sanft,\n",
      "Python wird zu Poesie.\n",
      "Einfach, schön.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "([4, 4, 2], 10)"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "anzWoerter = []\n",
    "\n",
    "for zeile in gedicht.splitlines():\n",
    "    \n",
    "    if len(zeile) > 0:\n",
    "        print(zeile)\n",
    "\n",
    "        anzWoerter.append(len( zeile.split()))\n",
    "\n",
    "anzWoerter, sum(anzWoerter)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "0287e0f7-f8a0-4c07-a9a1-4ab4d153d7ec",
   "metadata": {},
   "outputs": [],
   "source": [
    "Touringpreisträger = \"\"\"\n",
    "Donald E. Knuth\n",
    "10. Januar 1938\n",
    "Analyse von Algorithmen und Entwurf von Programmiersprachen. Sein mehrbändiges Werk The Art of Computer Programming gilt als „Bibel“ der Informatik.\n",
    "\n",
    "Tim Berners-Lee\n",
    "8. Juni 1955\n",
    "Erfindung des World Wide Web, von HTML, HTTP und dem ersten Webbrowser.\n",
    "\n",
    "Edgar F. Codd\n",
    "19. August 1923\n",
    "Erfindung des relationalen Modells für Datenbankmanagementsysteme,  das die Grundlage fast aller modernen Datenbanken bildet.\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "5c83d9af-c30b-4fcd-8a17-716d4ed7c0b5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Person='Donald E. Knuth', Geburtstag='10. Januar 1938', Leistung='Analyse von Algorithmen und Entwurf von Programmiersprachen. Sein mehrbändiges Werk The Art of Computer Programming gilt als „Bibel“ der Informatik.'\n",
      "\n",
      "Person='Tim Berners-Lee', Geburtstag='8. Juni 1955', Leistung='Erfindung des World Wide Web, von HTML, HTTP und dem ersten Webbrowser.'\n",
      "\n",
      "Person='Edgar F. Codd', Geburtstag='19. August 1923', Leistung='Erfindung des relationalen Modells für Datenbankmanagementsysteme,  '\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'Donald E. Knuth': {'Geboren': '10. Januar 1938',\n",
       "  'Leistung': 'Analyse von Algorithmen und Entwurf von Programmiersprachen. Sein mehrbändiges Werk The Art of Computer Programming gilt als „Bibel“ der Informatik.'},\n",
       " 'Tim Berners-Lee': {'Geboren': '8. Juni 1955',\n",
       "  'Leistung': 'Erfindung des World Wide Web, von HTML, HTTP und dem ersten Webbrowser.'},\n",
       " 'Edgar F. Codd': {'Geboren': '19. August 1923',\n",
       "  'Leistung': 'Erfindung des relationalen Modells für Datenbankmanagementsysteme,  '}}"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ergebnis = {}\n",
    "\n",
    "for absatz in Touringpreisträger.split(\"\\n\\n\"):\n",
    "    zeilen = [ z for z in absatz.split(\"\\n\", maxsplit=3) if len(z) > 0 ]\n",
    "    #print( f\"-----\\n{zeilen}\" )\n",
    "\n",
    "    Person = zeilen[0]\n",
    "    Geburtstag = zeilen[1]\n",
    "    Leistung = zeilen[2]\n",
    "\n",
    "    #Person, Geburtstag, Leistung =  zeilen\n",
    "    \n",
    "    print(f\"{Person=}, {Geburtstag=}, {Leistung=}\\n\")\n",
    "\n",
    "    ergebnis[Person] = { \"Geboren\": Geburtstag, \"Leistung\": Leistung} \n",
    "ergebnis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bea6149a-c884-40b3-86fb-5457f98244c3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f18db9bd-231e-48cb-bd2d-14c811d9c40c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
