#! /usr/bin/env python3.10 import shelve, os class steuer_rechner: def __init__(self, lohn_eingabe = int) -> None: self.lohneingabe = lohn_eingabe self.data_datei = os.path.dirname(os.path.realpath(__file__)) + os.sep + "data" self.month = ['Jan', 'Feb', 'Mae', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'] if not os.path.exists(self.data_datei): month_dict = dict.fromkeys(self.month, 0) with shelve.open(self.data_datei) as db: db['Lohn'] = month_dict with shelve.open(self.data_datei) as db: print(db['Lohn']) def modify_data (self, month = str, money = int): #check value yes_exist = False for check_value in self.month: if check_value == month: yes_exist = True if not yes_exist is True: print("false value") return False with shelve.open(self.data_datei, writeback=True) as db_data: db_data['Lohn'][month] = money return True def sum_calc(self): calc = 0 with shelve.open(self.data_datei) as db: for test in db['Lohn'].values(): calc = calc + test return calc def prozent_rechner(self, prozent): prozent_wert = self.lohneingabe * (prozent / 100) sum_wert = self.lohneingabe + prozent_wert sum_min = self.lohneingabe - prozent_wert return { "sum" : sum_wert, "wert": prozent_wert, "min" : sum_min } def lohn_steuer_klass2(self): pass def main(self): while True: my_input = input("Wollen Sie Daten hinzufügen y|n:") print(my_input) if not my_input == 'n' and not my_input == 'y': print("richtig") elif my_input == 'y': print("richtg eingabe y") elif my_input == 'n': print("raus") break #test = steuer_rechner.prozent_rechner(self, prozent=18.1) #modify_data = steuer_rechner.modify_data(self, month="Oktoo", money=1231.12) #sum_rechner = steuer_rechner.sum_calc(self) #print("Summe im Jahr :"sum_rechner) #print(modify_data) #print(self.lohneingabe) if __name__ == "__main__": rechnen = steuer_rechner(lohn_eingabe=232) rechnen.main()