Class - 12 CBSE Computer Science Important Output Questions 2025
Predict the output of the following code.
def code(n):
if n == 0:
print ( 'Finally' )
else:
print (n)
code (3)
code (15)
Python
Python Functions
1 Like
Answer
3
15
Working
The code defines a function code(n)
that takes a single argument n
. Inside the function, if the input n
is equal to 0, it prints "Finally", otherwise, it prints the value of n
. When called with code(3)
, it passes the argument 3 to the function. Since 3 is not equal to 0, the function prints 3. Similarly, calling code(15) prints 15 as it also doesn't meet the condition for 0.
Answered By
3 Likes