Computer Science · Python String Slicing
पायथन में निम्नलिखित पालिंड्रोम चेक एक्सप्रेशन के संबंध में तार्किक सत्य की पहचान कीजिए: def is_palindrome(s): return s == s[-1::-1]
- 1यह केवल विषम लंबाई (odd-length) वाली स्ट्रिंग्स के लिए सही ढंग से काम करता है।
- 2यह खाली स्ट्रिंग्स पर IndexError उत्पन्न करेगा।
- 3स्लाइस सिंटैक्स s[-1::-1] मान्य है, s[::-1] के समकक्ष है, और स्ट्रिंग को सही ढंग से उलट देता है, इसलिए कोई तार्किक त्रुटि नहीं है।✓
- 4स्लाइस सिंटैक्स गलत है; यह सख्ती से s[::-1] होना चाहिए।
सही उत्तर देखें
स्लाइस सिंटैक्स s[-1::-1] मान्य है, s[::-1] के समकक्ष है, और स्ट्रिंग को सही ढंग से उलट देता है, इसलिए कोई तार्किक त्रुटि नहीं है।
Download Single Question PDF
Save this question and verified answer as a clean study sheet with live clickable link.
Share with Friends & Study Groups
Challenge your peer aspirants on WhatsApp or Telegram to solve this question!
Preparing for Computer Science?
Practice full-length Computer Science mock tests with real exam timers, instant score analysis, and all-India ranking.
Want more practice questions on Python String Slicing?
Solve complete topic-wise tests with detailed solutions on GkGet.
Related Practice Questions
Recommended practice questions in Computer Science · Python String Slicing