Check sibling questions

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

Are ads bothering you?

CA Maninder Singh's photo - Expert in Practical Accounts, Taxation and Efiling

Made by

CA Maninder Singh

CA Maninder Singh is a Chartered Accountant for the past 12 years. He also provides Accounts Tax GST Training in Delhi, Kerala and online.