Skip to content
Q50Section DA (Data Science and Artificial Intelligence (Q11–Q65))50 of 65

Behaviour of closures created by separate calls to an outer function

Consider the given Python program.

def outer():
    x = []
    def inner(val):
        x.append(val)
        return x
    return inner
f1 = outer()
f2 = outer()
print(f1(10))   # Line P
print(f1(20))   # Line Q
print(f2(30))   # Line R
print(f1(40))   # Line S

Which of the following options is/are correct?

Multiple select: one or more options are correct. Select all of them, then submit — marks need the exact set.

Options

Select every correct option, then submit.