human
Complete this python program:
def instantiateAddCallbacksBeforeResult(n):
assistant
#Here is the Python program you requested.

    """Create a deferred and adds a trivial callback/errback/both to it the given
    number of times, and then shoots a result through all of the callbacks.
    """
    d = defer.Deferred()
    def f(result):
        return result
    for i in xrange(n):
        d.addCallback(f)
        d.addErrback(f)
        d.addBoth(f)
        d.addCallbacks(f)
    d.callback(1)