0% found this document useful (0 votes)
27 views2 pages

Python String Functions Hinglish

This document provides a comprehensive overview of various Python string functions categorized into basic functions, search and replace functions, formatting functions, character testing functions, and splitting and joining functions. Each function is described in Hinglish, detailing its purpose and usage. Examples are also provided to illustrate how these functions work in practice.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Python String Functions Hinglish

This document provides a comprehensive overview of various Python string functions categorized into basic functions, search and replace functions, formatting functions, character testing functions, and splitting and joining functions. Each function is described in Hinglish, detailing its purpose and usage. Examples are also provided to illustrate how these functions work in practice.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Python String Functions - Hinglish Notes

Basic String Functions (Basic wale kaam ke functions):

len(s) - String ki length (kitne characters hain) return karta hai.

s.upper() - Saare characters ko capital (uppercase) mein convert karta hai.

s.lower() - Saare characters ko small (lowercase) mein convert karta hai.

s.capitalize() - Sirf pehla letter capital karta hai.

s.title() - Har word ka first letter capital karta hai.

s.strip() - Aage aur peeche ke spaces hataata hai.

s.lstrip() - Sirf left side ke spaces hataata hai.

s.rstrip() - Sirf right side ke spaces hataata hai.

Search aur Replace wale functions:

s.find(sub) - Substring ki pehli position (index) return karta hai. Agar na mile to -1 deta hai.

s.index(sub) - Yeh bhi position deta hai, lekin agar na mile to error deta hai.

s.replace(old, new) - String ke andar jo old word hai usko new se replace karta hai.

s.count(sub) - Substring kitni baar aayi hai, uska count deta hai.

s.startswith(prefix) - Check karta hai ki string kis prefix se start ho rahi hai.

s.endswith(suffix) - Check karta hai ki string kis suffix pe end ho rahi hai.

Formatting Functions (String ko format karna):

s.format(val1, val2, ...) - {} ke jagah values daal kar string format karta hai.

f"{val1} text" - f-string ka use karke direct values add kar sakte ho.
s.zfill(width) - String ke left side mein zero add karta hai jab tak desired width na ho jaaye.

Character Testing Functions (Check karte hain string ke characters ko):

s.isalpha() - Check karta hai ki saare characters alphabets hain ya nahi.

s.isdigit() - Check karta hai ki string mein sirf numbers hain ya nahi.

s.isalnum() - Check karta hai ki alphabets ya numbers hain ya nahi (special characters nahi).

s.isspace() - Check karta hai ki string mein sirf space hai ya nahi.

s.islower() - Check karta hai ki saare letters small hain ya nahi.

s.isupper() - Check karta hai ki saare letters capital hain ya nahi.

Splitting aur Joining (String todna aur jodna):

s.split() - String ko tod deta hai list mein, space ke base par.

s.split(',') - Comma ya koi aur separator dekar tod sakte ho.

','.join(list) - List ke items ko jod kar ek single string bana deta hai.

Example in Hinglish:

text = " Hello Python "

print(len(text)) # 16 (length ke spaces bhi count hote hain)

print(text.strip()) # 'Hello Python' (space hata diye)

print(text.upper()) # ' HELLO PYTHON ' (capital letters)

print(text.find("Python")) # 8 (Python ki starting position)

You might also like