# a calculator für investition und finanzierung

#----------Variablen-------------------------------------

av = 2000           # Anlagevermögen
uv = 1000              # Umlaufvermögen
ford_kf = 250         # kurzfristige Forderungen
# lm = 100             # liquide Mitte

ek = 1100             # Eigenkapital
fk = 1900             # Fremdkapital
fk_kf = 100          # kurzfristiges Fremdkapital
fk_lf = 1800          # langfristiges Fremdkapital
verb_kf = 100        # kurzfristige Verbindlichkeiten
# verb_ki =         # Verbindlichkeiten gegenüber Kreditinstituten
z = 160               # Zinsen

umstz = 1550          # Umsatzerlöse
g = 140               # Gewinn = Umsatzerlös - Kosten
r_fk = 0.08         # Zinssatz  # ist jetzt eine Funktion

# cf = 100              # Cashflow
auf_mat = 250           # aufwand materialien
auf_pers = 1000         # Aufwand Personal
sonst = z               # sonstiger Aufwand

#-----------------------------------------------------------

#------------------------------------Funktionen-----------------------------------------------

# Vermögen--------------------------

def gesamtvermoegen(uv, av):
    global gv
    gv = uv + av
    print(f"gesamtvermoegen = {gv}")
    return gv


def gesamtkapital(fk, ek):
    global gk
    gk = fk + ek
    print(f"gesamtkapital = {gk}")
    return gk

def cashflow_brutto(*var):
    global cf
    cf = umstz - auf_mat - auf_pers - z - sonst
    print(f"cashflow_brutto = {cf}")
    return cf


# Vermögensstruktur-----------------

def anlagequote(av, gv):
    global q_av
    q_av = av / gv
    print(f"anlagequote = {q_av}")
    return q_av

# Kapitalstruktur--------------------

def eigenkapitalquote(ek, gk):
    global q_ek
    q_ek = ek / gk
    print(f"eigenkapitalquote = {q_ek}")
    return q_ek

# Finanzstruktur---------------------------

def anlagedeckungsgrad_i(ek,av):
    global adg_i
    adg_i = ek / av
    print(f"anlagedeckungsgrad I = {adg_i}")
    return adg_i

def anlagedeckungsgrad_ii(ek, fk_lf, av):
    global adg_ii
    adg_ii = ((ek + fk_lf) / (av))
    #print(f"anlagedeckungsgrad II = {adg_ii}")
    if adg_ii >= 1:
        print(f"anlagedeckungsgrad II = {adg_ii} >= 100% (über kritischem Wert)")
    else:
        print(f"anlagedeckungsgrad II = {adg_ii} < 100% (unter kritischem Wert)")
    return adg_ii
# Liquiditätsstruktur-----------------------

def liquiditaetsgrad_i(lm, verb_kf):
    global lg_i
    lg_i = lm / verb_kf
    if lg_i >= 0.2:
        print(f"liquiditätsgrad I = {lg_i} = >= 20% (gut)")
    else:
        print(f"liquiditätsgrad I = {lg_i} < 20% (schlecht)")
    return lg_i

def liquiditaetsgrad_ii(lm, ford_kf, verb_kf):
    global lg_ii
    lg_ii = ((lm + ford_kf) / (verb_kf))
    if lg_ii >= 1:
        print(f"liquiditätsgrad II = {lg_ii} >= 100% (über kritscihem Wert)")
    else:
        print(f"liquiditätsgrad II = {lg_ii} < 100% (unter kritischem Wert)")
    return lg_ii

def liquiditaetsgrad_iii(uv, verb_kf):
    global lg_iii
    lg_iii = uv / verb_kf
    if lg_iii >= 1.5:
        print(f"liquiditätsgrad III = {lg_iii} >= 150% (gut)")
    else:
        print(f"liquiditätsgrad III = {lg_iii} < 150% (schlecht)")

# Bilnaz------------------------------------

def bilanz_check(gv, gk):
    if gv == gk:
        print("""Bilanz:    gv = gk ,
        """)
    elif gv < gk:
        print("""Bilanz:    gv < g , Wenigar Vermögen als Kapital!
        """)
    elif gv > gk:
        print("""Bilanz:    gv > gk , mehr Vermögen als Kapital!
""")
    else:
        print("""
Bilanz nicht berechenbar
""")

# Rentabilität----------------------
def zinssatz(verb_ki, z):
    global r_fk
    r_fk = z / verb_ki
    print(f"zinssatz = {r_fk}")
    return r_fk

def eigenkapitalrentabilitaet(g, ek):
    global r_ek
    r_ek = g / ek
    print(f"eigenkapitalrentabilitaet = {r_ek}")
    return r_ek

def gesamtkapitalrentabilitaet(g, r_fk, fk, gk):
    global r_gk
    r_gk = ((g + (z))/gk)
    print(f"gesamtkapitalrentabilitaet = {r_gk}")
    return r_gk

def umsatzrentabilitaet(g, umstz):
    global r_umstz
    r_umstz = g / umstz
    print(f"umsatzrentabilitaet = {r_umstz}")
    return r_umstz

def cashflow_rendite(cf, umstz):
     global r_cf
     r_cf = cf / umstz
     print(f"cashflow_rendite = {r_cf}")
     return r_cf



def verschuldungsgrad(fk, ek):
    global v
    v = fk / ek
    print(f"verschuldungsgrad = {v}")
    return v


def eigenkapitalrentabilitaet_leverage(r_fk, r_gk, v):
    global r_ek_lev
    r_ek_lev = r_gk + (v * (r_gk - r_fk))
    print(f"""eigenkapitalrentabilitaet_leverage = {r_ek_lev}
""")
    return r_ek_lev



# Öffne Textdokument

# file_object = open("history.txt", "a")

# Ausführung der Funktionen-------------------------------------------


print("------------------------------Vermögen/Kapital----------------")


try:
    gesamtkapital(fk, ek)
except:
    print("gesamtkapital = n/b")
#----------------
try:
    gesamtvermoegen(uv, av)
except:
    print("gesamtvermögen = n/b")
#----------------
try:
    bilanz_check(gv, gk)
except:
    print("""Bilanz:    kein Bilanz_check möglich
    """)
#----------------
print("-------------------------------Quoten--------------------------")


try:
    anlagequote(av, gv)
except:
    print("anlagequote = n/b")
#----------------
try:
    eigenkapitalquote(ek, gk)
except:
    print("eigenkapitalquote = n/b")
#----------------
print("-----------------------------Rentabilitäten---------------------")


try:
    zinssatz(verb_ki, z)
except:
    print("zinssatz = n/b")
#----------------
try:
    eigenkapitalrentabilitaet(g, ek)
except:
    print("eigenkapitalrentabilitaet = n/b")
#----------------
try:
    gesamtkapitalrentabilitaet(g, r_fk, fk, gk)
except:
    print("gesamtkapitalrentabilitaet = n/b")
#----------------
try:
    umsatzrentabilitaet(g, umstz)
except:
    print("umsatzrentabilitaet = n/b")

#-------------------
try:
    cashflow_brutto()
except:
    print("cashflow_brutto = n/b")
#-----------------------
try:
    cashflow_rendite(cf, umstz)
except:
    print("cashflow_rendite = n/b")
#--------------------
try:
    verschuldungsgrad(fk, ek)
except:
    print("verschuldungsgrad = n/b")
#----------------
try:
    eigenkapitalrentabilitaet_leverage(r_fk, r_gk, v)
except:
    print("eigenkapitalrentabilitaet_leverage = n/b")
#----------------
print("--------------------------Anlagedeckungsgrad---------------------")


try:
    anlagedeckungsgrad_i(ek, av)
except:
    print("anlagedeckungsgrad I = n/b")
#----------------
try:
    anlagedeckungsgrad_ii(ek, fk_lf, av)
except:
    print("anlagedeckungsgrad II = n/b")
#----------------
print("---------------------------Liquiditaetsgrad----------------------")


try:
    liquiditaetsgrad_i(lm, verb_kf)
except:
    print("liquiditaetsgrad I = n/b")
#----------------
try:
    liquiditaetsgrad_ii(lm, ford_kf, verb_kf)
except:
    print("liquiditaetsgrad II = n/b")
#----------------
try:
    liquiditaetsgrad_iii(uv, verb_kf)
except:
    print("liquiditaetsgrad III = n/b")
#---------------- 
by

Python Online Compiler

Write, Run & Share Python code online using OneCompiler's Python online compiler for free. It's one of the robust, feature-rich online compilers for python language, supporting both the versions which are Python 3 and Python 2.7. Getting started with the OneCompiler's Python editor is easy and fast. The editor shows sample boilerplate code when you choose language as Python or Python2 and start coding.

Taking inputs (stdin)

OneCompiler's python online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample python program which takes name as input and print your name with hello.

import sys
name = sys.stdin.readline()
print("Hello "+ name)

About Python

Python is a very popular general-purpose programming language which was created by Guido van Rossum, and released in 1991. It is very popular for web development and you can build almost anything like mobile apps, web apps, tools, data analytics, machine learning etc. It is designed to be simple and easy like english language. It's is highly productive and efficient making it a very popular language.

Tutorial & Syntax help

Loops

1. If-Else:

When ever you want to perform a set of operations based on a condition IF-ELSE is used.

if conditional-expression
    #code
elif conditional-expression
    #code
else:
    #code

Note:

Indentation is very important in Python, make sure the indentation is followed correctly

2. For:

For loop is used to iterate over arrays(list, tuple, set, dictionary) or strings.

Example:

mylist=("Iphone","Pixel","Samsung")
for i in mylist:
    print(i)

3. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while condition  
    #code 

Collections

There are four types of collections in Python.

1. List:

List is a collection which is ordered and can be changed. Lists are specified in square brackets.

Example:

mylist=["iPhone","Pixel","Samsung"]
print(mylist)

2. Tuple:

Tuple is a collection which is ordered and can not be changed. Tuples are specified in round brackets.

Example:

myTuple=("iPhone","Pixel","Samsung")
print(myTuple)

Below throws an error if you assign another value to tuple again.

myTuple=("iPhone","Pixel","Samsung")
print(myTuple)
myTuple[1]="onePlus"
print(myTuple)

3. Set:

Set is a collection which is unordered and unindexed. Sets are specified in curly brackets.

Example:

myset = {"iPhone","Pixel","Samsung"}
print(myset)

4. Dictionary:

Dictionary is a collection of key value pairs which is unordered, can be changed, and indexed. They are written in curly brackets with key - value pairs.

Example:

mydict = {
    "brand" :"iPhone",
    "model": "iPhone 11"
}
print(mydict)

Supported Libraries

Following are the libraries supported by OneCompiler's Python compiler

NameDescription
NumPyNumPy python library helps users to work on arrays with ease
SciPySciPy is a scientific computation library which depends on NumPy for convenient and fast N-dimensional array manipulation
SKLearn/Scikit-learnScikit-learn or Scikit-learn is the most useful library for machine learning in Python
PandasPandas is the most efficient Python library for data manipulation and analysis
DOcplexDOcplex is IBM Decision Optimization CPLEX Modeling for Python, is a library composed of Mathematical Programming Modeling and Constraint Programming Modeling