# float: float oder integer
DEFAULT_B = 13  # all_caps

SPEED_OF_SOUND = 343


def divide(a, b):
    # nicht überprüfen ob b != 0 da dies ein fehler ist!
    return a / b

# : typehint
def convert_dog_to_human_age(dogage: int) -> int:
    """
    Konvertiert ein Hundealter in Menschenjahren.
    :param dogage: (int) Hundealter in Jahren
    :return (int): Entsprechendes alter in Menschenjahren
    Ein Hund ist immer ganze Jahre alt. z.B. 1, 2, 3, 4
    """
    # assert oder raise
    assert dogage >= 0, "ALter muss immer positiv sein"
    # assert isinstance(dogage, int), "Muss integer sein"
    human_age = 0  # lokale variable
    if dogage == 1:
        human_age = 14
    elif dogage == 2:
        human_age = 22
    elif dogage > 2:
        human_age = 22 + (dogage - 2) * 5

    return human_age

def substract_mean(lst: list[float]) -> None:
    mean = sum(lst) / len(lst)
    for i in range(len(lst)):
        lst[i] -= mean
    # diese Zeile steht immer bei fehlendem return am Ende
    return None

def create_mean_free_list(lst):
    res = []
    mean = sum(lst) / len(lst)
    for el in lst:
        res.append(el - mean)
    return res
# positionelle argumente, schlüsselwort-argumente
def foo(a, b=DEFAULT_B, verbose=0):
    # f-string
    # formatted-string
    print(f"a={a}")
    print(f"{b=}")
    print(f"{verbose=}")
    print(f"a/b = {a/b}")
    # r-string
    return a / b

def open_file(file_path: str):
    print(f"Opening {file_path}")

def food(bag=None, debug=False):
    # is und nicht ==
    # is vergleicht id
    if debug:
        print("Debug message")
    if bag is None:
        bag = []
    bag.append("Spam")
    return bag

def calculate_time(dist):
    # 1. in der Funktion nach SPEED_OF_SOUND
    # 2. Global im file + imports (selten nutzen)
    # 3. im eingebauten namensraum
    return dist / SPEED_OF_SOUND


def calc_circle_area(radius):
    return 3.14 * radius ** 2

def calc_rect_area(height, width):
    return height * width

def calc_area(shape, *sides: tuple[float], **kwargs):
    print(kwargs, type(kwargs))
    if "verbose" in kwargs:
        verbose = kwargs.pop("verbose")  # entfernt schlüssel verbose und gibt den dazugehörigen wert zurück
        print(verbose)
    if shape.lower() == "circle":
        return calc_circle_area(*sides, **kwargs)
    elif shape.lower() == "rectangle":
        return calc_rect_area(*sides, **kwargs)  # args[0], args[1]
    else:
        raise ValueError(f"Shape {shape} is not yet supported, Circle, Rectangle")

def complete_function(pos_arg1, pos_argn, *args, kw1=True, kwn="N", **kwargs):
    print(pos_arg1)

if __name__ == "__main__":
    dst = 10
    print("test")
    t = "hello"
    # Beispiele
    print(__name__)
    scooby_doo = 6
    scooby_name = "Scooby doo"
    scooby_doo_human = convert_dog_to_human_age(scooby_doo)
    print(scooby_doo_human)
    divide(5, 1)
    numbers = [42, 14, 7, 11, 13, 39]
    print(numbers, id(numbers))
    res = numbers.copy()
    substract_mean(res)
    print(numbers)
    numbers.insert(0, -1)
    print(numbers)
    foo(31, verbose=2)
    foo(10, b=3)
    foo(b=5, a=2)  # nicht schreiben
    datei = r"C:\neuer Ordner\neuesfile"  # raw-string
    open_file(datei)
    res = food()
    print(res)
    res2 = food()
    print(res2)
    res3 = food()
    print(res3)
    print(res)
    l1 = [101, 102, 103]
    l2 = [101, 102, 103]
    print(l1 == l2)
    t = calculate_time(10)
    print(t)
    area = calc_area("rectangle", 5, 2)
    print(area)
    area = calc_area("circle", 4, verbose=True)
    print(area)
    rect = [6, 2]
    ra = calc_rect_area(*rect)
    print(ra)