What will be the output of the following code segment? a = 5निम्नलिखित कोड सेगमेंट का आउटपुट क्या होगा?
What will be the output of the following code segment?
a = 5
def func_1(b=10):
global a
a=b-10
b+=a
print (a,b)
func_1(a)
निम्नलिखित कोड सेगमेंट का आउटपुट क्या होगा?
a = 5
def func_1(b=10):
global a
a=b-10
b+=a
print (a,b)
func_1(a)
Show answerHide answer
Correct answer: (D) -5 0-5 0
Explanation
func_1(5) is called, so b = 5. The function declares a as global, sets a = 5 − 10 = −5, then b += a makes b = 0, and it prints "-5 0".func_1(5) बुलाया जाता है, इसलिए b = 5। फ़ंक्शन a को global घोषित करता है, a = 5 − 10 = −5 करता है, फिर b += a से b = 0 होता है, और वह "-5 0" प्रिंट करता है।