Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 3 : A

Advertisement

Detailed Solution

सही उत्तर A है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

What does the following Python try-finally code output? / try-finally वाले निम्नलिखित Python कोड का आउटपुट क्या है? def g(): try: return 'A' finally: print('B', end='') print(g())

1.
BA
2.
AB
3.
A
4.
B

Correct Answer: A

The finally block always runs before the return completes, so 'B' prints first and then the returned 'A' prints: BA. / finally ब्लॉक return पूरा होने से पहले हमेशा चलता है, इसलिए पहले 'B' छपता है फिर लौटाया गया 'A': BA।

Downloaded from PrepSnap (prepsnap.in)