[Python] How to programm a function yielding average value of a list of values using...

Discussão em 'Python' iniciado por Stack, Julho 10, 2025.

  1. Stack

    Stack Membro Participativo

    It's hard to apply functional programming to python in a strict way. Particulary if a counter is needed changing for any invokation using recursion. Any recommendations?

    My solutions so far are mediocre like calc_average(count, list) ...

    How can I modify to avoid providing two parameters to the function instead of one (the list itself) ?

    def calc_average(anzahl,nums):
    match nums:
    case():
    return 0
    case(summe, *rest):
    return (summe/anzahl + calc_average(anzahl,rest))

    Continue reading...

Compartilhe esta Página