{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "724c85cc-a668-47f9-ba15-3f6c68a93d8e",
   "metadata": {},
   "source": [
    "# WS2026 KW 41"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "307907e8",
   "metadata": {},
   "source": [
    "Taschenrechner mit Zahlen (Integer, Float)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4a6c9f86-b161-441e-9aa4-52b17058d353",
   "metadata": {},
   "outputs": [],
   "source": [
    "2+3.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fcb2a0b2-f09a-4fad-a21f-7461f27eef36",
   "metadata": {},
   "outputs": [],
   "source": [
    "x = 2*3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fed31038-544c-4d2c-9bf1-b84fa0a86de5",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "32936ff9-6ca4-4856-b8db-9a235314953e",
   "metadata": {},
   "outputs": [],
   "source": [
    "b = b + 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ff89515a-f16a-4615-a646-fc51f220d9af",
   "metadata": {},
   "outputs": [],
   "source": [
    "a, b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b65aae14-f84e-4a22-8d3b-ad093cac8d35",
   "metadata": {},
   "outputs": [],
   "source": [
    "dasisteinelangevariable = 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9dcc98d7-b73d-44b1-a2c7-51caf69b3dcc",
   "metadata": {},
   "outputs": [],
   "source": [
    "dasistschoen = 7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "ab5c1ddf-f74b-4898-912e-566cd79c93ee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dasisteinelangevariable"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "67bc0901-7756-432e-87dc-76aafcfd1729",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "e5d38798",
   "metadata": {},
   "source": [
    "Taschenrechner mit Strings, Listen"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "34a0ab48",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hallohallo'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "h = \"hallo\"\n",
    "2*h"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aba3ada0",
   "metadata": {},
   "source": [
    "List(String); Index; Slicing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9c807376",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['h', 'a', 'l', 'l', 'o']"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(h)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "2e7c521a-568c-4468-afb0-1bc71a8d439d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hal'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "h[0:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "c3890ff9-da25-43ab-8c53-3876ad6a2517",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['l', 'l', 'o']"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "h_liste = ['h', 'a', 'l', 'l', 'o']\n",
    "h_liste[2:99]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "f30bebb8-4807-4f13-aa76-f1d0f0208fa6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'a'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display( h_liste[1] )"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4c154b86",
   "metadata": {},
   "source": [
    "eine Funktion `quadriere(x)` definieren"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "5f63d4fe",
   "metadata": {},
   "outputs": [],
   "source": [
    "def quadriere(x):\n",
    "    q = x*x\n",
    "    return q\n",
    "\n",
    "def dopple(x):\n",
    "    return x+x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "4d41c4d9-efdd-428b-9654-1c337c82a1fc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'HalloHallo'"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dopple(\"Hallo\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2062699c-969d-4cb6-a9f2-23a558fa2e23",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "1105df43",
   "metadata": {},
   "source": [
    "Menge von Quadratzahlen mit set comprehension"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "be03b844",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n",
      "9\n",
      "16\n",
      "25\n"
     ]
    }
   ],
   "source": [
    "meine_zahlen = [ 2, 3, 4, 5 ]\n",
    "for x in meine_zahlen:\n",
    "    print( quadriere(x) )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "56111e30-cf1f-44fc-9219-87e345d3fe19",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{4, 9, 16, 25}"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "{ quadriere(x) for x in meine_zahlen }"
   ]
  }
 ],
 "metadata": {
  "jupytext": {
   "default_lexer": "ipython3",
   "formats": "ipynb,md:myst"
  },
  "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
}
