Class - 12 CBSE Computer Science Important Output Questions 2025
Find and write the output of the following python code :
a = 10
def call():
global a
a = 15
b = 20
print(a)
call()
Python
Python Functions
3 Likes
Answer
15
Working
a = 10
— This line assigns the value 10 to the global variablea
.def call()
— This line defines a function namedcall
.a = 15
— Inside the call function, this line assigns the value 15 to the global variablea
. Asglobal
keyword is used earlier, this assignment modifies the value of the global variablea
.b = 20
— Inside the call function, this line assigns the value 20 to a local variableb
.print(a)
— This line prints the value of the global variablea
, which is 15. This is because we've modified the global variablea
inside the call function.
Answered By
2 Likes