Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
AKIS Python Notebooks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christof Kaufmann
AKIS Python Notebooks
Commits
c6ba25fe
Commit
c6ba25fe
authored
1 year ago
by
Christof Kaufmann
Browse files
Options
Downloads
Patches
Plain Diff
Notebooks from ckaufmann/akis-python-framework@c7384d48
parent
f775bde3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
12-funktionen/02-kreis-sol.ipynb
+6
-6
6 additions, 6 deletions
12-funktionen/02-kreis-sol.ipynb
with
6 additions
and
6 deletions
12-funktionen/02-kreis-sol.ipynb
+
6
−
6
View file @
c6ba25fe
...
@@ -51,15 +51,15 @@
...
@@ -51,15 +51,15 @@
"output_type": "stream",
"output_type": "stream",
"name": "stdout",
"name": "stdout",
"text": [
"text": [
"Fläche = 12.566370614359172"
"
'
Fläche = 12.566370614359172
'
"
]
]
}
}
],
],
"source": [
"source": [
"a, p = kreis(2)\n",
"a, p = kreis(2)\n",
"
print(
'Fläche =
', a)
"
"
f
'Fläche =
{a}'
"
],
],
"id": "0007-3
14184afe68554751c7be4e5c1d3869239904f6387804556655fb86f36e
"
"id": "0007-3
b6b3da3fe9a7f07555268a04ef491a59107c8470a875cc4a01d432af9c
"
},
},
{
{
"cell_type": "code",
"cell_type": "code",
...
@@ -70,14 +70,14 @@
...
@@ -70,14 +70,14 @@
"output_type": "stream",
"output_type": "stream",
"name": "stdout",
"name": "stdout",
"text": [
"text": [
"Umfang = 12.566370614359172"
"
'
Umfang = 12.566370614359172
'
"
]
]
}
}
],
],
"source": [
"source": [
"
print(
'Umfang =
', p)
"
"
f
'Umfang =
{p}'
"
],
],
"id": "0008-3ce
43a0e8c461119da67a8327e30ce2083d20bd59ee4635792578a34d2d
"
"id": "0008-3ce
215e6fc995ede85579bf438743c42d45e695fca38d8f28a3ce631e8b
"
},
},
{
{
"cell_type": "markdown",
"cell_type": "markdown",
...
...
%% Cell type:markdown id:0005-8eb736fd54ed821975c03a16c39231ddccf05ddfd1f695c6df94bbc2877 tags:
%% Cell type:markdown id:0005-8eb736fd54ed821975c03a16c39231ddccf05ddfd1f695c6df94bbc2877 tags:
# Fläche und Umfang eines Kreises
# Fläche und Umfang eines Kreises
Schreiben Sie eine Funktion
`kreis`
, die den Radius eines Kreises
Schreiben Sie eine Funktion
`kreis`
, die den Radius eines Kreises
übergeben bekommt. Die Funktion soll die den Flächeninhalt und den
übergeben bekommt. Die Funktion soll die den Flächeninhalt und den
Umfang zurück geben. Testen Sie ihre Funktion, indem Sie die Funktion
Umfang zurück geben. Testen Sie ihre Funktion, indem Sie die Funktion
aufrufen und beide Rückgabewerte einzeln ausgeben.
aufrufen und beide Rückgabewerte einzeln ausgeben.
*
Hinweis: Die Konstante $
\p
i$ können Sie auf zwei Arten als
`pi`
*
Hinweis: Die Konstante $
\p
i$ können Sie auf zwei Arten als
`pi`
importieren:
*
importieren:
*
-
`from math import pi`
-
`from math import pi`
-
`from numpy import pi`
-
`from numpy import pi`
## Lösung
## Lösung
Die Fläche eines Kreises ist $a =
\p
i · r^2$. Der Umfang eines Kreises
Die Fläche eines Kreises ist $a =
\p
i · r^2$. Der Umfang eines Kreises
ist $p = 2 ·
\p
i · r$. Die Funktion muss also wie folgt aussehen:
ist $p = 2 ·
\p
i · r$. Die Funktion muss also wie folgt aussehen:
%% Cell type:code id:0006-8a4072981d3849089a57c1035af2196faea238c016a8dd6199a587dff1b tags:
%% Cell type:code id:0006-8a4072981d3849089a57c1035af2196faea238c016a8dd6199a587dff1b tags:
```
```
def kreis(radius):
def kreis(radius):
from math import pi
from math import pi
area = pi * radius**2
area = pi * radius**2
perimeter = 2 * pi * radius
perimeter = 2 * pi * radius
return area, perimeter
return area, perimeter
```
```
%% Cell type:code id:0007-3
14184afe68554751c7be4e5c1d3869239904f6387804556655fb86f36e
tags:
%% Cell type:code id:0007-3
b6b3da3fe9a7f07555268a04ef491a59107c8470a875cc4a01d432af9c
tags:
```
```
a, p = kreis(2)
a, p = kreis(2)
print(
'Fläche =
', a)
f
'Fläche =
{a}'
```
```
%% Output
%% Output
Fläche = 12.566370614359172
'
Fläche = 12.566370614359172
'
%% Cell type:code id:0008-3ce
43a0e8c461119da67a8327e30ce2083d20bd59ee4635792578a34d2d
tags:
%% Cell type:code id:0008-3ce
215e6fc995ede85579bf438743c42d45e695fca38d8f28a3ce631e8b
tags:
```
```
print(
'Umfang =
', p)
f
'Umfang =
{p}'
```
```
%% Output
%% Output
Umfang = 12.566370614359172
'
Umfang = 12.566370614359172
'
%% Cell type:markdown id:0009-372eb0d1de051c603302b93ade3cf670777fb8a6b5cf61edddc34915eba tags:
%% Cell type:markdown id:0009-372eb0d1de051c603302b93ade3cf670777fb8a6b5cf61edddc34915eba tags:
## Tests
## Tests
%% Cell type:code id:0010-4ea26216dd150daa8aa32c2eb73f68b326ca887fe37ea8a307a28983f0e tags:
%% Cell type:code id:0010-4ea26216dd150daa8aa32c2eb73f68b326ca887fe37ea8a307a28983f0e tags:
```
```
a, p = kreis(4)
a, p = kreis(4)
print(f'Fläche = {a:.2f}')
print(f'Fläche = {a:.2f}')
```
```
%% Output
%% Output
Fläche = 50.27
Fläche = 50.27
%% Cell type:code id:0011-f9e4563bafc5a1597829e05bc456cd486620134933c2dc287d635206a9b tags:
%% Cell type:code id:0011-f9e4563bafc5a1597829e05bc456cd486620134933c2dc287d635206a9b tags:
```
```
print(f'Umfang = {p:.2f}')
print(f'Umfang = {p:.2f}')
```
```
%% Output
%% Output
Umfang = 25.13
Umfang = 25.13
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment