Table of Contents
Python Tutorial
Table of Contents
Python Tutorial
Python String in Hindi
What is Python String
Python String : Single and double quote के अंदर हम कुछ लिखते हैं तो यह string कहलाता है.
Triple quote के अंदर हम कुछ लिखते हैं तो भी यह string कहलाता है इसका use हम multi line string के लिए करते हैं.
String Indexing
अगर हम string में से किसी specific data को print करना चाहते हैं तो indexing का use करते हैं.
python string में characters का indexing 0 से start होता है, और negative indexing end से start होता है -1 last character को represent करता है.
String Slicing
slicing का use string के Sab string पाने के लिए होता है,
start: Ye wo index hai jahan se slicing start hoti hai.
stop: Ye wo index hai jahan tak slicing hoti hai.
step: Ye optional parameter hai jo batata hai ki kitne steps ka difference rakhna hai.
Agar aap start, stop, ya step ko nahi dete, to default values use hoti hain:
Default value for start is 0.
Default value for stop is length of the string.
Default value for step is 1
String Concatenation
string concatenation का मतलब होता है एक या एक से अधिक strings को add करके single string मे convert करना।
string को concatenate करने के लिए + operator या join methode का use किया जाता है।
NOTE: string concatenation मे हमने double quote ( ” ” ) का use इसलिए किया है ताकि हम strings के बीच मे space दे सके अगर double quote नहीं लगाएंगे तो सारे strings एक मे mix होकर single word बन जाएंगे।
अगर आप double quote के अंदर कुछ लिखेंगे तो वो भी string मे join हो जाएगा।
String Formatting
अगर हम चाहते है कि string मे variables या expressions के value को direct insert कर सके तो हमे string formatting का उसे करना होगा। python मे string formatting बनाने के लिए % operator, str.format() method और f-strings का use करते है।
% Operator
str.format Method
f-strings
String Methods
python मे string के लिए कई सारे build-in methods होते है जिन्हे use करने पर string अलग अलग तरीके से perform करता है।
Syntex:
method को किसी भी variable के साथ use करने के लिए dot ( . ) का use करते है।
Example:
str.upper() : इस method का use करके हम string के सभी lower case letters को upper case मे कर सकते है।
upper(): String को uppercase मे convert करता है।
lower(): String को lowercase मे convert करता है।
capitalize(): पहला letter uppercase करता है, बाकी lowercase
title(): हर word का पहला letter uppercase करता है।
strip(): Start और end के whitespace (या characters) remove करता है।
lstrip(): Left से whitespace (या characters) remove करता है।
rstrip(): Right से whitespace (या characters) remove करता है।
replace(old, new): String मे किसी substring को replace करता है।
split(separator): String को list मे break करता है।
str.join(iterable): List (या iterable) को string मे add करता है।
str.find(sub): Substring का index return करता है (अगर नहीं मिल तो -1 return करेगा)
str.index(sub): Substring का index देता है।
str.count(sub): Substring कितनी बार आया है, वो count करता है।
str.isalpha(): Check करता है की सब characters alphabets है या नहीं अगर है तो true return करेगा।
str.isdigit(): Check करता है की सभी characters digits है या नहीं अगर है तो true return करेगा।
str.isalnum(): Alphabets + Digits है तो True return करता है ।
str.isspace(): अगर string मे सिर्फ whitespace है तो True return करेगा।
str.islower(): Check करता है की string lowercase मे है या नहीं। अगर है तो true return करेगा।
str.isupper(): Check करता है की string uppercase मे है या नहीं, अगर है तो true return करेगा।
उम्मीद करते है कि आपको python string अच्छे समझ मे आ गया होगा । अपने learning को continue रखने के लिए next button पर click करे,
- All Posts
- Artificial Intelligence
- Computer Fundamentals
- Computer Networks
- Data Analytics
- Data Science
- DBMS
- Deep Learning
- Digital Electronics
- DSA with Python
- Excel
- Exercise
- Git & Github
- Machine Learning
- Matplotlib
- Natural Language Processing
- NumPy
- Operating System
- Pandas-s
- Power BI
- Python Tutorial
- Scikit-learn
- Seaborn
- SQL & MySQL

Table of Contents All Chapters 1. Personal Area Network 2. Local Area Network 3. Campus Area Network 4. Metropolitan Area...

Table of Contents All Chapters 1. Data Communication 2. Types of Data Communication 2.1. Simplex 2.2....

Table of Contents All Chapters 1. Special Logic Gate 2. XOR Gate 2.1. XOR Gate Truth Table 3....

Table of Contents All Chapters 1. Universal Logic Gates 2. NOR Gate 2.1. NOR Gate Truth Table 3....

Table of Contents All Chapters 1. Logic Gate 2. AND Gate 2.1. AND Gate Truth Table 3. OR...

Table of Contents All Chapters 1. Simplification 2. Simplification using Boolean Algebra Theorems 3. Simplification using K-map Digital Electronics...

Table of Contents All Chapters 1. Identity Laws 2. Null Laws 3. Domination Laws 4. Idempotent Laws 5. Complement Laws...