CBSE Class 12 Computer Science
Question 78 of 103
Working with Functions — Question 11
Back to all questionsThe code raises an error when executed.
In the provided code, the global variables a and y are initialized to 10 and 5, respectively. Inside the myfunc function, the line a = 2 suggests that a is a local variable of myfunc. But the line before it, y = a is trying to assign the value of local variable a to local variable y even before local variable a is defined. Therefore, this code raises an UnboundLocalError.