16. Lektion: Funktionen.extend(): Difference between revisions
Jump to navigation
Jump to search
| Line 13: | Line 13: | ||
>>> | >>> | ||
</pre> | </pre> | ||
'''Alternative:''' | |||
<pre> | |||
>>> def test2(a, b): | |||
return (a, b) | |||
>>> z = test2(3.14, 42) | |||
>>> z | |||
(3.14, 42) | |||
>>> x, y = z | |||
>>> x | |||
3.14 | |||
>>> y | |||
42 | |||
>>> | |||
</pre> | |||
==== Positions- oder Schlüsselwortargumente==== | ==== Positions- oder Schlüsselwortargumente==== | ||
Revision as of 16:58, 1 October 2023
Funktionen
Mehrere Ergebnisse zurückgeben
>>> def test1(a, b):
return a, b
>>> x, y = test1(3.14, 42)
>>> x
3.14
>>> y
42
>>>
Alternative:
>>> def test2(a, b):
return (a, b)
>>> z = test2(3.14, 42)
>>> z
(3.14, 42)
>>> x, y = z
>>> x
3.14
>>> y
42
>>>
Positions- oder Schlüsselwortargumente
Zufallszahlen
Zurück zu Micropython Kurs 2023 - Teil 1
Zurück zur "Micropython Kurs 2023" Startseite
Zurück zur Programmieren Startseite
Zurück zur Wiki Startseite