Technologische_Grundlagen/course/python/04-functions.ipynb

125 lines
2.2 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "2aa66773-49ef-43bd-8f86-84a9ea68c4d4",
"metadata": {},
"source": [
"### Functions"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "53eaee4f-539c-4a5e-baf2-1f45077eebb0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"2\n",
"3\n",
"4\n",
"5\n",
"6\n",
"7\n",
"8\n",
"Funktion ausgabe durchlaufen\n"
]
},
{
"data": {
"text/plain": [
"36"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def ausgabe(endwert, anfangswert=1, schrittweite=1):\n",
" summe = 0\n",
" for x in range(anfangswert, endwert, schrittweite):\n",
" print(x)\n",
" summe = summe + x\n",
" print(\"Funktion ausgabe durchlaufen\")\n",
" return summe\n",
"\n",
"ausgabe(9)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "e9bc89ad-6b67-4109-b6d6-f74218cfe304",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"2\n",
"3\n",
"4\n",
"5\n",
"6\n",
"7\n",
"8\n",
"9\n",
"10\n",
"11\n",
"Funktion ausgabe durchlaufen\n"
]
},
{
"data": {
"text/plain": [
"66"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ausgabe(12)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7e207043-c521-48ef-9ee4-b0e6f8ce2164",
"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.11.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}