-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.py
More file actions
36 lines (28 loc) · 770 Bytes
/
functions.py
File metadata and controls
36 lines (28 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Functions
def myFunction():
print("Meine Funktion!")
def funcWithArgs(a, b, c):
print(a, b, c)
def retVal(a, b):
return a + b
def retVals(a, b, c, d):
v1 = a + b
v2 = c + d
v3 = a + d
v4 = b + c
return v1, v2, v3, v4
# beliebig viele Argumente übergeben
# Hinweis: Schlüsselwortargumente mit dem Operator **
def maFunc(*args):
for e in args: # 1 2 3 4 Text 5 6 7 8 9 Text
print(e, end=' ')
print("\nAnzahl Argumente:", len(args)) # 11
# Funktionen aufrufen
myFunction()
funcWithArgs(1, 2, 3)
x = retVal(1, 2) # 3
print(x)
print(retVals(1, 2, 3, 4)) # (3, 7, 5, 5)
# Speicherstelle einer Funktion
print(myFunction) # <function myFunction at 0x...>
maFunc(1,2,3,4,"Text",5,6,7,8,9,"Text")