[GER]Python Code um den Internen Zinssatz zu ermitteln. [ENG]Python code to calculate the irr.
Archived 7 months ago
M
𝑴𝑰𝑺𝑺𝑪𝑶𝑪𝑶✰
Verified
[GER] Hi, ich bin duale Studentin und muss für eins meiner fächer den Internen Zinssatz für eine Investition per Python ermitteln. Es gibt ein "Lösungsbild" was in der Kommandozeile rauskommen soll, jedoch keine anderen Hilfestellungen und bekomme es leider nicht alleine hin. Mein jetziger Code sieht so aus [siehe unten]. Falls jemand mir Tipps / Verbesserungsvorschläge / eine gute Website Empfehlung geben kann wäre das super. Vielen dank schon einmal <3.
[ENG] Hi, I am a dual student and have to calculate the internal rate of return for an investment using Python for one of my subjects. There is a “solution image” which should come out in the command line, but no other help and unfortunately I can't do it on my own. My current code looks like this [see below]. If anyone can give me tips / suggestions for improvement / a good website reccomendation that would be great. Many thanks in advance <3.
[CODE]:
# Output UI-Kopfzeile
print ("Dynamische Investitionsrechnung mit folgenden Parametern: \n")
# Input aus UI
def Parameter_eingeben ():
N = int (input ("Nutzungsdauer des Investitionsobjekts \t\t\t[Jahre] N = "))
i_start = float (input ("Kalkulationszinssatz \t\t\t\t\t[\u0025] \t i = "))
I0 = float (input ("Anschaffungskosten zum Zeitpunkt t0 \t\t\t[\u20ac] \t I0 = "))
return N, i_start, I0
def Rueckfluesse_eingeben (N):
Rueckfluesse = []
print ("\nRückflüsse Rt (Auszahlungsreihe):")
for z in range (1, N +1):
Rueckfluesse.append (float(input (" in Periode " + str(z) + "\t\t\t\t\t\t[\u20ac]\t R" + str(z) + " = ")))
z += 1
return Rueckfluesse
def InternerZinssatz_erstellen (i_start):
i_int = [i_start]
for a in range (i_start, i_start +0.00001):
i_int.append (float(pass))
a += 0.00001
return i_int
# Output in UI
def Kapitalwert_ausgeben (C0N):
print ("-----------------------------------------------------------------------------"
"\n\u21d2 Kapitalwert der Investition zum Zeitpunkt t=0\t\t[\u20ac]\t C0N = ", float(C0N))
# -------------------------------------------------------------------------------------
# Control: Verarbeitungsfunktionen, Prozesse
def Barwerte_berechnen (N, i_int, I0, Rueckfluesse):
q = 1 + i_int/100
Barwerte = []
for z in range (0, len (Rueckfluesse)):
Barwerte.append (round (Rueckfluesse [z] * q**-(z+1), 2))
z += 1
return Barwerte
def Kapitalwert_berechnen (I0, Barwerte):
C0N = -I0 + sum (Barwerte)
return C0N
def Iteration_schleife (C0N):
pos_C0N = []
neg_C0N = []
while C0N > 0.00001 True:
pos_C0N.append (pass)
if C0N < -0.00001 True:
neg_C0N.append (pass)
return pos_C0N, neg_C0N
def Schleife_beenden (C0N):
if C0N == 0.00001 or C0N == -0.00001
break
# =====================================================================================
# MAIN
# Parametereingabe
N, i_start, I0 = Parameter_eingeben ()
Rueckfluesse = Rueckfluesse_eingeben (N)
#Schleife-Beginnen
while C0N != pass
# Kapitalwertberechnung
i_int = InternerZinssatz_erstellen (i)
Barwerte = Barwerte_berechnen (N, i_int, I0, Rueckfluesse)
C0N = Kapitalwert_berechnen (I0, Barwerte)
pos_C0N, neg_C0N = Iteration_schleife (C0N)
#Schleife-Beenden
C0N == Schleife_beednen (C0N)
# Kapitalwertausgabe
InternerZins_ausgeben (pass)
Kapitalwert_ausgeben (C0N)
![[GER]Python Code um den Internen Zinssatz zu ermitteln. [ENG]Python code to calculate the irr.](/_next/image?url=https%3A%2F%2Fcdn.discordapp.com%2Fattachments%2F1376544119333060722%2F1376544119572140194%2FScreenshot_2025-05-26_145358.png%3Fex%3D6967921d%26is%3D6966409d%26hm%3D980c9fdd64ad2345a4cb2cfd768a520a25a2cfcfbc9d7a9ac8f36c9de9b78fee%26&w=1920&q=75)
