Q. From the program given below, identify the scope of each variable in the program.


x = 10 # Reference 1
pi = 3.14
def incr(x): # Reference 2
y = x + 1
return y
def area(r):
n = incr(r)
ar =pi * n * n
return ar
incr(5)
print(x)
area(4)


Answer :-

 
Variable Name Scope
x Global variable
pi Global variable
y Local variable
n Local variable
ar Local variable

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post