Computer Science · Python String Slicing
निम्नलिखित पायथन (Python) कोड स्निपेट पर विचार कीजिए: s = 'Computer Science' print(s[20]) print(s) कथन A (पहला प्रिंट) और कथन B (दूसरा प्रिंट) के व्यवहार में सटीक अंतर क्या है?
- 1दोनों कथन सफलतापूर्वक निष्पादित होते हैं; कथन A अंतिम अक्षर देता है, और B सबस्ट्रिंग देता है।
- 2कथन A एक IndexError उत्पन्न करता है, जबकि कथन B आउट-ऑफ-बाउंड इंडेक्स को सुचारू रूप से संभालते हुए 'cience' देता है।✓
- 3कथन A एक खाली स्ट्रिंग '' देता है, जबकि कथन B एक IndexError उत्पन्न करता है।
- 4दोनों कथन IndexError उत्पन्न करते हैं क्योंकि इंडेक्स सीमा से बाहर है।
सही उत्तर देखें
कथन A एक IndexError उत्पन्न करता है, जबकि कथन B आउट-ऑफ-बाउंड इंडेक्स को सुचारू रूप से संभालते हुए 'cience' देता है।
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 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