Test Index

CBSE Class 12 Computer Science 2025 Paper Compartment Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 12 of 37
Marks: +1, -0
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)
Solution:  
Concept:
A value passed in the call replaces the default value of the parameter. global a makes the function use (and change) the global variable a.
Explanation:
func_1(a) is called with a = 5, so b = 5 (the default 10 is not used).
a = b - 10 = 5 − 10 = −5 (global a becomes −5)
b += a → b = 5 + (−5) = 0
print(a, b) →
-5 0
Key point: The default b=10 applies only when no argument is passed; using it would give 0 10.
Answer:
Option D (-5 0)
© examsnet.com
Advertisements
Go to Question: