NB_03_Funktionen_und_Ein-_und_Ausgabe¶
(c) 2025 Technische Hochschule Augsburg - Fakultät für Informatik - Prof.Dr.Nik Klever - Impressum
Funktionen¶
Funktionen¶
In [2]:
def d(x,y):
return max(x,y)
def e(c):
return 5*c
def f(g):
return g(5)
a = d(2,3)
b = e(2)
c = f(e)
print("a={}\nb={}\nc={}".format(a,b,c))
a=3 b=10 c=25
In [3]:
%%Mooc Video
Out[3]:
Ein- und Ausgabe¶
In [9]:
a = "Dies ist eine erste Zeile"
b = "... und eine zweite Zeile"
with open("textdatei.txt","w") as f:
f.write(a)
with open("textdatei.txt","a") as f:
f.write(b)
with open("textdatei.txt","r") as f:
c = f.read()
print("a={}\nb={}\nc={}".format(a,b,c))
a=Dies ist eine erste Zeile b=... und eine zweite Zeile c=Dies ist eine erste Zeile... und eine zweite Zeile