Commit 13935093 authored by Tauon's avatar Tauon

Upload New File

parent f918915e
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Funktionen\n",
"\n",
"Mit Funktionen bieten die Möglichkeit Code Stellen wieder zu verwenden ohne sie hin und her zu kopieren.\n",
"\n",
"Eine Funkion trägt einen Namen wie eine Variable. Sie kann mehrere Übergabeparameter haben und mehrere Werte zurück geben. So lassen sich Funktionen dynamisch in weiteren Code einbieten."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Definition der Funktion my_function\n",
"def my_function():\n",
" print(\"Hello from a function\")\n",
"\n",
"# Funktion aufrufen\n",
"my_function()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Definition der Funktion my_function\n",
"def my_function(parameter_1, parameter_n):\n",
" print(\"parameter_1: %s parameter_n: %s\" % (parameter_1, parameter_n)) \n",
"\n",
"# Funktion aufrufen\n",
"my_function(\"Teil1\",\"Teil2\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def is_leap_year(year):\n",
" leap_year = False\n",
"\n",
" if year % 400 == 0:\n",
" leap_year = True\n",
" elif year % 100 == 0:\n",
" leap_year = False\n",
" elif year % 4 == 0:\n",
" leap_year = True\n",
"\n",
" return leap_year\n",
"\n",
"print(is_leap_year(1984))\n",
"print(is_leap_year(1983))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.5.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment