{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "cell-0",
   "metadata": {
    "editable": false,
    "tags": [
     "aufgabe"
    ]
   },
   "source": [
    "## Aufgabe: Schlüsseldienst (Funktion)\n",
    " \n",
    "Sie sollen für einen Schlüsseldienst ein Python-Programm schreiben, um den Preis eines Einsatzes zu berechnen.\n",
    "\n",
    "Abhängig von der Länge der Anfahrt wird eine Anfahrtspauschale berechnet:\n",
    "\n",
    "\n",
    "- Für \"kilometer\" unter 37 zahlen Sie 11 Euro\n",
    "- Für \"kilometer\" kleiner als 65 und mindestens 37 zahlen Sie 20 Euro\n",
    "- Für \"kilometer\" größer oder gleich 65 zahlen Sie 67 Euro\n",
    "\n",
    "\n",
    "Zusätzliche kostet jede Minute Arbeitszeit 3.4 Euro.\n",
    "\n",
    "Wird ein Nachtzuschlag fällig, erhöht sich der berechnete Preis um 38 Euro.\n",
    " \n",
    "Hier finden Sie Beispieldaten für diese Aufgabe:\n",
    "\n",
    "<table border=\"1\" class=\"dataframe\">\n",
    "  <thead>\n",
    "    <tr style=\"text-align: right;\">\n",
    "      <th>Kunde</th>\n",
    "      <th>Gefahrene Kilometer</th>\n",
    "      <th>Arbeitszeit (min)</th>\n",
    "      <th>Nachtzuschlag</th>\n",
    "      <th>Preis</th>\n",
    "    </tr>\n",
    "  </thead>\n",
    "  <tbody>\n",
    "    <tr>\n",
    "      <td>Meier</td>\n",
    "      <td>136</td>\n",
    "      <td>71</td>\n",
    "      <td></td>\n",
    "      <td>308.40</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>Kohler</td>\n",
    "      <td>59</td>\n",
    "      <td>44</td>\n",
    "      <td></td>\n",
    "      <td>169.60</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>Meyer</td>\n",
    "      <td>101</td>\n",
    "      <td>93</td>\n",
    "      <td>ja</td>\n",
    "      <td>421.20</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>Schneider</td>\n",
    "      <td>138</td>\n",
    "      <td>15</td>\n",
    "      <td>ja</td>\n",
    "      <td>156.00</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>Schmidt</td>\n",
    "      <td>94</td>\n",
    "      <td>75</td>\n",
    "      <td>ja</td>\n",
    "      <td>360.00</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>Müller</td>\n",
    "      <td>50</td>\n",
    "      <td>46</td>\n",
    "      <td></td>\n",
    "      <td>176.40</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>Werner</td>\n",
    "      <td>112</td>\n",
    "      <td>93</td>\n",
    "      <td>ja</td>\n",
    "      <td>421.20</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "      <td>Meyer</td>\n",
    "      <td>135</td>\n",
    "      <td>97</td>\n",
    "      <td>ja</td>\n",
    "      <td>434.80</td>\n",
    "    </tr>\n",
    "  </tbody>\n",
    "</table> \n",
    "\n",
    "Der Aufruf der Funktion erfolgt mit\n",
    "\n",
    "`berechnePreis(kilometer, arbeitszeit, nachtzuschlag)`\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "cell-1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-10-14T07:10:23.503313Z",
     "iopub.status.busy": "2025-10-14T07:10:23.502994Z",
     "iopub.status.idle": "2025-10-14T07:10:23.509024Z",
     "shell.execute_reply": "2025-10-14T07:10:23.508112Z",
     "shell.execute_reply.started": "2025-10-14T07:10:23.503280Z"
    }
   },
   "outputs": [],
   "source": [
    "# Die folgenden Daten können Sie zum Testen verwenden:\n",
    "testdaten = [\n",
    " ['Meier', 136.0, 71.0, '', 308.4],\n",
    " ['Kohler', 59.0, 44.0, '', 169.6],\n",
    " ['Meyer', 101.0, 93.0, 'ja', 421.2],\n",
    " ['Schneider', 138.0, 15.0, 'ja', 156.0],\n",
    " ['Schmidt', 94.0, 75.0, 'ja', 360.0],\n",
    " ['Müller', 50.0, 46.0, '', 176.4],\n",
    " ['Werner', 112.0, 93.0, 'ja', 421.2],\n",
    " ['Meyer', 135.0, 97.0, 'ja', 434.8]\n",
    "]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "cell-2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-10-14T07:10:23.952489Z",
     "iopub.status.busy": "2025-10-14T07:10:23.952179Z",
     "iopub.status.idle": "2025-10-14T07:10:23.956680Z",
     "shell.execute_reply": "2025-10-14T07:10:23.955789Z",
     "shell.execute_reply.started": "2025-10-14T07:10:23.952460Z"
    }
   },
   "outputs": [],
   "source": [
    "# Hier ist Platz für Ihre Lösung\n",
    "def anfahrtspauschale(km):\n",
    "    if km < 37:\n",
    "        return 11\n",
    "    else:\n",
    "        if km >= 11 and km < 65:\n",
    "            return 20\n",
    "        else:\n",
    "            return 67"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6303503f-83a2-43c7-a5bc-1332f8ee31e0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-10-14T07:10:24.556825Z",
     "iopub.status.busy": "2025-10-14T07:10:24.556519Z",
     "iopub.status.idle": "2025-10-14T07:10:24.561008Z",
     "shell.execute_reply": "2025-10-14T07:10:24.559913Z",
     "shell.execute_reply.started": "2025-10-14T07:10:24.556798Z"
    }
   },
   "outputs": [],
   "source": [
    "def anfahrtspauschale2(km):\n",
    "    if km < 37:\n",
    "        return 11\n",
    "\n",
    "    if km < 65:\n",
    "        return 20\n",
    "    \n",
    "    return 67"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "0d30513d-ff7a-41e1-885d-b3ab39cb023d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-10-14T07:10:25.206652Z",
     "iopub.status.busy": "2025-10-14T07:10:25.206329Z",
     "iopub.status.idle": "2025-10-14T07:10:25.214814Z",
     "shell.execute_reply": "2025-10-14T07:10:25.213934Z",
     "shell.execute_reply.started": "2025-10-14T07:10:25.206625Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "20"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "anfahrtspauschale2(40)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "7097c0f4-0f0b-4c65-944e-c73fdf900cf0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-10-14T07:10:25.706061Z",
     "iopub.status.busy": "2025-10-14T07:10:25.705752Z",
     "iopub.status.idle": "2025-10-14T07:10:25.709548Z",
     "shell.execute_reply": "2025-10-14T07:10:25.708631Z",
     "shell.execute_reply.started": "2025-10-14T07:10:25.706033Z"
    }
   },
   "outputs": [],
   "source": [
    "# Hier ist Platz für Ihre Lösung"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "d7ffcf9e-4be5-48b6-925b-f6aaec7e4375",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-10-14T07:10:26.107681Z",
     "iopub.status.busy": "2025-10-14T07:10:26.107384Z",
     "iopub.status.idle": "2025-10-14T07:10:26.111887Z",
     "shell.execute_reply": "2025-10-14T07:10:26.111011Z",
     "shell.execute_reply.started": "2025-10-14T07:10:26.107654Z"
    }
   },
   "outputs": [],
   "source": [
    "def berechnePreis(kilometer, arbeitszeit, nachtzuschlag):\n",
    "\n",
    "    pauschale = anfahrtspauschale(kilometer)\n",
    "    arbeitspreis = arbeitszeit * 3.4\n",
    "    zuschlag = 0\n",
    "    if nachtzuschlag == \"ja\":\n",
    "        zuschlag = 38\n",
    "\n",
    "    return pauschale + arbeitspreis + zuschlag"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a6e8fbb6-8ea3-4c1a-9f5f-1f2b5c73907a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-10-14T07:11:16.592742Z",
     "iopub.status.busy": "2025-10-14T07:11:16.592361Z",
     "iopub.status.idle": "2025-10-14T07:11:16.597878Z",
     "shell.execute_reply": "2025-10-14T07:11:16.597187Z",
     "shell.execute_reply.started": "2025-10-14T07:11:16.592713Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "421.2"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "berechnePreis( 101, 93, 'ja' )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e3b5be9d-1cf2-4633-a3ac-0aa5ff812a75",
   "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.12.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
