Creating Strings (स्ट्रिंग बनाना) :-
Creating Strings (स्ट्रिंग बनाना) का अर्थ है Python में किसी Text (पाठ), Character (अक्षर), Word (शब्द) या Sentence (वाक्य) को String के रूप में बनाना और उसे किसी Variable में Store करना।
Python में String बनाने के लिए Characters को Quotes (उद्धरण चिह्नों) के अंदर लिखा जाता है। Python चार प्रकार के Quotes का समर्थन करता है:
English
Creating Strings means creating a String object in Python to store text, characters, words, or sentences.
In Python, a String is created by enclosing text within quotation marks (quotes). Python supports four types of quotes:
Syntax (सिंटैक्स) -
variable_name = "String"
Methods of Creating Strings (स्ट्रिंग बनाने के तरीके)
Python में String निम्नलिखित तरीकों से बनाई जा सकती है:
1. Creating String Using Single Quotes (' ') :-
Single Quotes का उपयोग सामान्य (Simple) String बनाने के लिए किया जाता है।
Single quotes are commonly used to create simple strings.
Example-
Double Quotes भी Single Quotes की तरह कार्य करते हैं। इनका उपयोग विशेष रूप से तब किया जाता है जब String में Apostrophe (') हो।
Double quotes work the same as single quotes. They are useful when the string contains an apostrophe (').
Example-Triple Single Quotes का उपयोग Multi-line String (एक से अधिक पंक्तियों वाली स्ट्रिंग) लिखने के लिए किया जाता है।
Triple single quotes are used to create multi-line strings.
Example-Triple Double Quotes भी Multi-line String बनाने के लिए उपयोग किए जाते हैं।
Triple double quotes are also used to create multi-line strings.
Example -Python में str() Function का उपयोग किसी Value को String में बदलने या नई String बनाने के लिए किया जाता है।
The str() function is used to create a string or convert another data type into a string.
Example 1 -