CBSE Class 12 Computer Science Question 75 of 101

Functions — Question 43

Back to all questions
43
Question

Question 37(c)

Predict the output of the following code.

def code(n):
    if n == 0:
       print(' Finally') 
    else:
       print (n)
code (10)
Answer
Output
10
Explanation

This code defines a function called code(n) that takes a single argument n. Inside the function, there's a conditional statement that checks if n is equal to 0. If n is indeed 0, it prints the string " Finally". Otherwise, it prints the value of n. When the function code(10) is called, it passes the argument 10 to the function. Since 10 is not equal to 0, the function prints 10.