Files
INF6B/functions/umrechner.py

32 lines
983 B
Python
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def euroToDollar(euro_amount, kurs=1.15):
return euro_amount * kurs
def dollarToEuro(dollar_amount, kurs=1.15):
return dollar_amount / kurs
def main():
print("WährungsUmrechner ")
print("Aktueller Kurs: 1€ = {:.2f}USD".format(1.15))
richtung = input("1) € auf $ \n 2) $ auf € \nIhre Wahl: ")
if richtung == "1":
euro_str = input("€: ")
try:
euro = float(euro_str.replace(",","."))
dollar = euroToDollar(euro, kurs=1.15)
print(f"{euro:.2f}€ entsprechen {dollar:.2f}$")
except ValueError as e:
print(e)
elif richtung == "2":
usd_str = input("$: ")
try:
usd = float(usd_str.replace(",","."))
euro = dollarToEuro(usd, kurs=1.15)
print(f"{usd:.2f}$ entsprechen {euro:.2f}")
except ValueError as e:
print(e)
else:
print("wähle richtig")
if __name__ == "__main__":
main()