Question

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

Option 4 : NOHTYP

Advertisement

Detailed Solution

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

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

What does the following Python recursive string-reversal code output? / स्ट्रिंग उलटने वाले पुनरावर्ती Python कोड का आउटपुट क्या है? def rev(s): return s if len(s) <= 1 else rev(s[1:]) + s[0] print(rev('PYTHON'))

1.
PYTHON
2.
NOHTY
3.
NOPYTH
4.
NOHTYP

Correct Answer: NOHTYP

The recursion peels the first character to the end at each step, reversing the string: rev('PYTHON') = 'NOHTYP'. / पुनरावृत्ति प्रत्येक चरण में पहला अक्षर अंत में ले जाती है, जिससे स्ट्रिंग उलट जाती है: rev('PYTHON') = 'NOHTYP'।

Downloaded from PrepSnap (prepsnap.in)