CBSE · 083Class XII · 2024Section B2 marks
Question 25
2 April 2024 · Computer Science (083)
Predict the output of the following code :
python
def callon(b=20, a=10):
b = b + a
a = b - a
print(b, "#", a)
return b
x = 100
y = 200
x = callon(x, y)
print(x, "@", y)
y = callon(y)
print(x, "@", y)Answer
text
300 # 100
300 @ 200
210 # 200
300 @ 210Explanation
First call: b=100+200=300, a=300-200=100, returns 300 (assigned to x). Second call uses default a=10: b=200+10=210, a=210-10=200, returns 210 (assigned to y).