Carefully analyse the given Python program and determine the outputs produced…
2026
Carefully analyse the given Python program and determine the outputs produced during program execution by answering the following question.
A, B = 10, 20 # Line 01
def Fun(A=30): # Line 02
global B # Line 03
A += 5 # Line 04
B -= 5 # Line 05
print(A, B) # Line 06
return A + B # Line 07
A = Fun(B) # Line 08
print(A, B) # Line 09
B = Fun() # Line 10
print(A, B) # Line 11(A) What output will be displayed by the print statement in Line 06 when the function Fun is called in Line 08?
(B) What output will be displayed by the print statement in Line 09?
(C) What output will be displayed by the print statement in Line 06 when the function Fun is called in Line 10?
(D) What output will be displayed by the print statement in Line 11?
Show answer & explanation
(A) Output at Line 06 (Function call at Line 08):
Function is called as
Fun(B)→ value of B (20) is passed to ALocal A = 20 → after increment A = 25
Global B is modified: B = 20 − 5 = 15
Hence, print(A, B) gives:
Output : 25 15
(B) Output at Line 09:
Function returns A + B = 25 + 15 = 40
So, A becomes 40 and B = 15
Output : 40 15
(C) Output at Line 06 (Function call at Line 10):
Function is called without argument → default A = 30
After increment A = 35
Global B = 15 − 5 = 10
Output : 35 10
(D) Output at Line 11:
Function returns 35 + 10 = 45
So, B = 45 and A remains 40
Output : 40 45
Final Answers:
(A) 25 15
(B) 40 15
(C) 35 10
(D) 40 45