<data:blog.pageTitle/>

This Page

has moved to a new address:

http://hindimeter.com

Sorry for the inconvenience…

Redirection provided by Blogger to WordPress Migration Service
Hindi meter: Python Numbers and strings in hindi

गुरुवार, 27 अगस्त 2020

Python Numbers and strings in hindi

Numbers and strings in python-  नमस्कार दोस्तों! Python tutorial के इस आर्टिकल में हम python programming के कुछ basic डेटा टाइप जैसे int, float, string सीखेंगे। जैसे Integer क्या है, strings क्या है, python Integer और strings examples, आदी। क्यों कि इन्हें सूरुवाती तौर पे सिखना बेहद जरूरी है , इनका इस्तेमाल सभी programs में किया जाता है। बाकी डेटा टाइप जैसे list, tuple, dictionary, set जो की बेसिक डेटा टाइप नहीं है उन्हे हम बाद में सीखेंगे।
Python numbers and strings examples hindi
Python numbers and strings

Integer और strings की प्रोग्रामिंग में बेहद महत्वपूर्ण भूमिका है, इनका हर प्रोग्राम में इस्तेमाल होता है। इसलिए integers और strings को प्रोग्रामिंग के basic building blocks कहा जाता है।



Integers क्या है:

पूर्णांक दशमलव (decimal points) विरहित अंको को integers कहा जाता है। Integers positive, negative और zero भी हो सकते है। जैसे integers हमने स्कूल के गणित में पढ़े है ठीक उसी तरह के integers python में इस्तेमाल कीये जाते है। बस उनमें थोड़ा सा फरक है।
Integers के उदाहरण: 2, -6, 88, -277, आदी
1:  x=15  
2:  y=7  
3:  z=x+y  
4:  print(z)  
Output:
 22  
गणित में किसी भी अंक के बाद पूर्णांक दशमलव (decimal point) है और उसके बाद सभी शुन्य है तो उस पूर्णांक दशमलव का कोई महत्व नहीं रहता उसे integer ही मानते है लेकिन पाइथन में ऐसा नहीं होता।
जैसे हम गणित में 2.0 अंक को integer मानते है लेकिन इसी 2.0 को पाइथन में floating point माना जाता है।

चलिए अब हम देखते है कि floating points क्या होते है।


Floating points किसे कहते है:

पूर्णांक दशमलव अंको को (numbers with decimal points) को  floating points कहा जाता है।

Floating points के उदाहरण: 2.0, 66.7, 83.09, 0.9, आदी
1:  x=10.5  
2:  y=3.2  
3:  z=x+y  
4:  print(z)  
Output:
  13.7  

Strings क्या है:

   " The sequence of characters is called as a string"

पाइथन में शब्दों के अनुक्रम को string कहते है। जैसे अंग्रेजी में sentence (वाक्य) होते है उन्हे ही पाइथन में string के रूप में जाना जाता हैं। String को प्रोग्राम में लिखते समय single और double quotes के अंदर लिखते है।

String के उदाहरण: "This is a string" , 'john' , "my name is pralhad" , '4' , आदी
1:  x="My name is"  
2:  y="Abhay"  
3:  z=x+y  
4:  print(z)  
Output:
1:  My name is Abhay  
यदि हमने string को quotes के बगैर प्रोग्राम में लिखा तो interpreter प्रोग्राम में त्रुटि दर्शाता है। इसलिए प्रोग्राम में string को quotes के अंदर लिखना अनिवार्य है। आप अपने हिसाब से single या double quotes इस्तेमाल कर सकते हैं। सामान्यतः केवल एक शब्द वाले string में single quotes इस्तेमाल करते है और string में अगर एक से ज्यादा शब्द हो तो double quotes को इस्तेमाल करते हैं।

पाइथन में अंकों (numbers) को integer मानते है लेकिन यदि उसी अंकों को अगर हम quotes के अंदर लिखे तो वह string कहलाता है।
जैसे 4 एक integer है लेकिन इसे quotes के अंदर लिखे तो वह '4' string बन जाता है।

पाइथन में दो integers को add करने तथा दो strings को जोड़ने के लिए + operater का उपयोग किया जाता है।
जैसे निम्नलिखित उदाहरण में स्पष्ट किया है

  >>> 4   
  4   
  >>> '4'   
  '4'   
  >>> 5+8+2   
  15   
  >>> '5'+'8'+'2'    
  582   
  >>> 'ABC' + 'DEF'   
  ABCDEF   

पाइथन में दो strings को जोड़ने की प्रक्रिया को  string concatenation कहते है।
1:  x="Even number is"  
2:  y=2  
3:  z=x+y  
4:  print(z)  
Output:

 Interpreter shows error  
यदि हम प्रोग्राम में 5 (integer) + '7' (string) को जोड़ने का प्रयास करते हैं, तो interpreter त्रुटि दिखाता है क्योंकि + ऑपरेटर दो अलग-अलग प्रकार के मानों को जोड़ता या समेटता नहीं है।

लेबल:

0 टिप्पणियाँ:

एक टिप्पणी भेजें

सदस्यता लें टिप्पणियाँ भेजें [Atom]

<< मुख्यपृष्ठ