Class - 12 CBSE Computer Science Important Output Questions 2025
What will be the output of the following Python code ?
V = 25
def Fun(Ch):
V = 50
print(V, end = Ch)
V *= 2
print(V, end = Ch)
print(V, end = "*")
Fun("!")
print(V)
- 25*50!100!25
- 50*100!100!100
- 25*50!100!100
- Error
Python
Python Functions
10 Likes
Answer
25*50!100!25
Working
V = 25
— initializes global variable V to 25.print(V, end = "*")
— Prints the global variableV
(25) followed by an asterisk without a newline.Fun("!")
— Calls the functionFun
with the argument "!".- Inside function
Fun
,V = 50
initializes a local variableV
within the function with the value 50. This variable is different from the global variableV
that has the value 25. print(V, end = Ch)
— Prints the local variableV
(50) followed by the character passed as an argument to the function, which is "!".V *= 2
— Multiplies the local variableV
(50) by 2, making it 100.print(V, end = Ch)
— Prints the updated local variable V (100) followed by the character "!".- The function
Fun
returns and the lineprint(V)
is executed. It prints the global variableV
without any newline character. The global variableV
remains unchanged (25).
Answered By
2 Likes