STRING IN PYTHON – Hinglish Notes
1. What is a String?
String ek sequence of characters hoti hai jo single, double ya triple quotes me likhi jaati hai. Python
me strings immutable hoti hain.
Example:
name = "Arun"
city = 'Delhi'
2. String Indexing
Indexing se hum characters ko position ke through access karte hain. Index 0 se start hota hai.
Example:
s = "Python"
s[0] → P
s[-1] → n
3. String Slicing
Slicing ka matlab string ka ek part nikalna. End index include nahi hota.
Example:
s[0:4] → Pyth
s[::-1] → Reverse string
4. String Concatenation
Do ya zyada strings ko + operator se joda jaata hai.
5. String Functions
upper(), lower(), capitalize(), title(), strip(), replace(), find(), count(), split(), join()
6. String Immutability
String ke characters directly change nahi kiye ja sakte.
7. Escape Characters
\n – New line, \t – Tab, \\ – Backslash
8. String Formatting
Old style (%), format(), aur f-strings (recommended).
9. Common Programs
Reverse string, Palindrome check, Vowel count.
Important Exam Points
• Strings are immutable
• Indexing starts from 0
• f-strings fastest hote hain