human
I am working on the file "Closure a dekorator.ipynb".
The first task is:
Na vypocet potrebujeme uchovavat stav: sumu a pocet hodnot. Kde sa uklada stav?

V globalnej premennej? Nie, nechceme si zapratat priestor mien nejakymi nahodnymi premennymi, ktore by nam mohol hocikto prepisat.
Potrebuje nieco, co nam tie premenne schova.

Nieco taketo by sa dalo implementovat pomocou uzaveru
Can you write Python code for it?
 Write me a the Python code you requested?
assistant
#Here is the Python code you requested.

def make_averager():
    series = [] # tato premenna je platna len vo funkcii make_averager. Je pre nu lokalna. Mimo nej neexistuje.
    def averager(new_value):
        series.append(new_value) # vieme pristupit k premennej definovanej vyssie. 
        # Kedze list je mutable, tak ho vieme aj zmenit. Pozor, nemenime premennu, menime objekt! 
        # Aby sme menili premennu, tak by tu muselo byt = 
        total = sum(series)
        return total/len(series)
    return averager

avg = make_averager()
print(avg(10))
print(avg(11))
print(avg(12))