print() function in python
इस फंक्शन का उपयोग आउटपुट स्क्रीन पर जानकारी दिखाने के लिए किया जाता है।
This function is used to display information on the output screen.
syntax: print("string")
example: print("swapnilslab.com")
result: swapnilslab.com
उपरोक्त उदाहरण में print() एक फंक्शन है तथा स्ट्रिंग "swapnilslab.com" एक फंक्शन मान (फंक्शन आर्गुमेंट) कहलाता है।
In the above example print() is a function and the string "swapnilslab.com" is called a function value (function argument).
NOTE:
स्ट्रिंग एक ऐसा डाटा टाइप होता है जो अक्षरों से मिलकर बना होता है तथा जिसे डबल ( " ) या सिंगल ( ' ) क्वोट्स के अंदर लिखा जाता है।
A string is a data type that consists of letters and is written inside double ( " ) or single ( ' ) quotes.
स्ट्रिंग के अंदर एस्केप सीक्वेंसेस का उपयोग भी किया जा सकता है। एस्केप सीक्वेंसेस ऐसे करैक्टर होते हैं जिनका विशेष मतलब होता है। जैसे - '\n' नई लाइन दर्शाता है।
Escape sequences can also be used inside a string. Escape sequences are characters that have special meaning. eg - '\n' indicates new line.
example: print('hello\ndear')
result:
hello
dear
एक से अधिक स्ट्रिंग्स को जोड़ने के लिए + का उपयोग किया जा सकता है।
+ can be used to concatenate more than one string.
example: print('hello' + 'dear')
result: hellodear
वेरिएबल्स के मान को डिस्प्ले करने के लिए उनके नाम का उपयोग करें बिना सिंगल या डबल क्वोट्स का उपयोग किये।
To display the value of variables, use their name without using single or double quotes.
example:
a = 5
print(a)
result: 5
sep argument in print()
To display characters between multiple outputs, use the sep argument.
example:
print('hello', 'dear', sep='-')
result: hello-dear
end argument in print()
The end argument is used to represent the last character of the output.
result: hellodear#
यदि आप end आर्गुमेंट की वैल्यू नहीं लिखते हैं तो यह नई लाइन करैक्टर '\n' पर सेट होता है।
If you do not specify a value for the end argument, it is set to the new line character '\n'.
OTHER TOPIC:
Comments
Post a Comment