Class - 12 CBSE Computer Science Important Output Questions 2025
Find and write the output of the following python code :
def Call(P = 40, Q = 20):
P = P + Q
Q = P - Q
print(P, '@', Q)
return P
R = 200
S = 100
R = Call(R, S)
print(R, '@', S)
S = Call(S)
print(R, '@', S)
Python
Python Functions
44 Likes
Answer
300 @ 200
300 @ 100
120 @ 100
300 @ 120
Working
- Function Call is defined with two parameters
P
andQ
with default values 40 and 20 respectively. - Inside the function Call,
P
is reassigned to the sum of its original valueP
and the value ofQ
. Q
is reassigned to the difference between the new value ofP
and the original value ofQ
.- Prints the current values of
P
andQ
separated by @. - The function returns the final value of
P
. - Two variables
R
andS
are initialized with values 200 and 100 respectively. - The function Call is called with arguments
R
andS
, which are 200 and 100 respectively. Inside the function,P
becomes 200 + 100 = 300 andQ
becomes 300 - 100 = 200. So, 300 and 200 are printed. The function returns 300, which is then assigned toR
. Therefore,R
becomes 300. S = Call(S)
— The function Call is called with only one argumentS
, which is 100. Since the default value ofQ
is 20,P
becomes 100 + 20 = 120, andQ
becomes 120 - 20 = 100. So, 120 and 100 are printed. The function returns 120, which is then assigned toS
. Therefore,S
becomes 120.
Answered By
13 Likes