निम्नलिखित में से कौन सा कथन अंतिम रूप से निष्पादित होगा?
Which of the following statement will execute in last ?
def s(n1): #Statement 1
print(n1) #Statement 2
n2=4 #Statement 3
s(n2) #Statement 4 A
Statement 1
B
Statement 2
C
Statement 3
D
Statement 4
Explanation
Let's analyze the given code step by step:
def s(n1): # Statement 1
print(n1) # Statement 2
n2 = 4 # Statement 3
s(n2) # Statement 4
Execution Order:
- Statement 1: The function
s(n1)is defined. This statement does not execute anything immediately; it only defines the function. - Statement 3:
n2 = 4assigns the value4ton2. This is a regular assignment statement. - Statement 4:
s(n2)calls the functions()withn2(which is4). This triggers the execution of the function, so the next statement to execute is inside the function. - Statement 2: Inside the function,
print(n1)is executed, printing the value ofn1, which is4.
Conclusion:
The last statement to be executed is Statement 2, because it's inside the function s() and runs when the function is called in Statement 4.
Answer:
(B) Statement 2
Correct Answer: B) Statement 2