हिंदी

Observe the given Python code carefully: a=20 def convert(a): b=20 a=a+b convert(10) print(a) Select the correct output from the given options:

Advertisements

प्रश्न

Observe the given Python code carefully:

a=20
def convert(a):
      b=20
      a=a+b

convert(10)
print(a)

Select the correct output from the given options:

विकल्प

  • 10

  • 20

  • 30

  • Error

MCQ
Advertisements

उत्तर

20

Explanation:

The convert function changes the local variable 'a' value, which serves as the function's formal parameter. The printed value is the global variable 'a' value, which remains unchanged at 20.

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2023-2024 (March) Set 4
Advertisements
Share
Notifications



      Forgot password?
Use app×