Test Index
Functions in Python
© examsnet.com
Question : 14 of 23
Marks:
+1,
-0
Predict the output of the following code :
def callon(b=20,a=10): b=b+a a=b-a print(b,"#",a) return bx=100y=200x=callon(x,y)print(x,"@",y)y=callon(y)print(x,"@",y)
[CBSE 2024 Set 4]
Solution:
Output:
300 # 100300 @ 200210 # 200300 @ 210Explanation:
x = callon(100, 200): b = 100 + 200 = 300, a = 300 - 200 = 100. Prints 300 # 100 and returns 300, so x = 300.print(x,"@",y) prints 300 @ 200.y = callon(200): b = 200, a takes its default 10. b = 210, a = 210 - 10 = 200. Prints 210 # 200 and returns 210, so y = 210.print(x,"@",y) prints 300 @ 210.Key point: print() separates its items with a space by default, so a space appears on both sides of # and @.© examsnet.com
Go to Question: