Find and write the output of the following python code:

a=10

def call():

global a

a=15

b=20

print(a)

call()

 

 

Answer:

  • a is initially declared as a global variable and assigned the value 10
  • Then a function call( ) is created where a is assigned the value 15 and b is assigned the value 20. So now, the value of a is updated from 10 to 15 .
  • a is printed when the function is called.
  • So, the output will be 15.

Question 1 - Teachoo.jpg

Ask a doubt
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.