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
13 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 functionFunwith the argument "!".- Inside function
Fun,V = 50initializes a local variableVwithin the function with the value 50. This variable is different from the global variableVthat 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
Funreturns and the lineprint(V)is executed. It prints the global variableVwithout any newline character. The global variableVremains unchanged (25).
Answered By
2 Likes