Assuming that the following code has been executed successfully, which of the expressions evaluate to True? (Choose two.)
Assuming that the following code has been executed successfully, which of the expressions evaluate to True? (Choose two.)
The function f(x, y) defines a nested function g() that returns the result of dividing x by y (nom by denom). When f(1, 2) is called, it returns the function g which will return 1/2 when invoked with a(). Similarly, f(3, 4) returns a different function g that will return 3/4 when invoked with b(). Therefore, a and b are different functions, making 'a != b' True. Also, since a is assigned to a function returned by f, 'a is not None' is True.
B. a != b C. a is not None
Example Closure , def f(x, y): nom, denom = x, y def g(): return nom / denom return g a = f(1, 2) b = f(3, 4) fun1 = a fun2 = b print(fun1()) print(fun2())
def f(x,y): nom,denom = x,y def g(): return nom/denom return g a=f(1,2) b=f(3,4) print(a is not None) print(a!=b) print(a() == 4) print(b() == 4) B,C