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

Remove Ads Share on WhatsApp
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh is an IIT Kanpur graduate and has been teaching for 16+ years. At Teachoo, he breaks down Maths, Science and Computer Science into simple steps so students understand concepts deeply and score with confidence.

Many students prefer Teachoo Black for a smooth, ad-free learning experience.