<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: Indentation, identifiers and keywords in python

शुक्रवार, 28 अगस्त 2020

Indentation, identifiers and keywords in python

Indentation,identifiers and keywords in python- नमस्कार दोस्तों! Python tutorial के इस आर्टिकल में हम indentation, identifiers और keywords के बारे में जानेंगे।
Indentation क्या है
Indentation, Identifier and keywords

 जैसे -
  • Indentation क्या है
  • Identifiers किसे कहते है
  • Identifiers को लिखने के नियम
  • Python keywords क्या है
  • List of python keywords

Indentation

पाइथन कोड में लाइन की शुरूवात में मौजूद खुली जगह (space or tabs) को indentation की रूप में पारिभाषित किया जाता है।

अन्य प्रोग्रामिंग भाषाओं की तुलना में पाइथन में indentation सबसे महत्वपूर्ण है।  पाइथन में indentation का उपयोग code blocks को दर्शाने के लिए किया जाता है।

समान खुली जगह (indentation) छोड़कर लिखे गए python statements एक ही प्रकार के होते हैं।

चलिए निम्न उदाहरण से हम indentation को समझ ते है:
1:  x=int(input("Enter a number"))  
2:  if x%2==0:  
3:    print(x,"is a even number")  
4:  else:  
5:    print (x,"is a odd number")  
उपर दिए गए उदाहरण में दोनों print statements को if or else statement के नीचे indented किया है।यदि पहली condition सही है तो if statement के नीचे दिया print statement execute होगा। अगर पहली condition गलत होगी तो फिर else के नीचे indented किया हुआ print statement execute होगा। 

Identation से interpreter को पता चलता है कि कोनसा statement को execute करना है।


Identifiers and keywords:

Identifiers जो variables, functions, classes, objects, आदी जैसे python entities को दिए गए नाम होते है।

यह दो मात्राओं के बीच अंतर करने में मदद करता है।

Rules for writing identifiers:

चलिए अब हम समझ ते है कि identifiers को लिखने के क्या नियम है।
  1. Identifiers अंग्रेजी लेटर्स uppercase (A to Z), lowercase (a to z), अंक (0 to 9) और underscore symbol ( _ ) का संयोग होता है। उदा: x, var_num , sum2 आदी
  2. Identifier अंक के साथ शुरू नहीं हो सकता है। उदा: 1var, 3num मान्य Identifiers नहीं है।
  3. Python keywords का उपयोग Identifiers के रूप में नहीं किया जा सकता है। उदा: break, class, false, print आदी मान्य Identifiers नहीं है।
  4. हम underscore ( _ )  को छोड़कर @, #, $, जैसे विशेष प्रतीकों का उपयोग Identifiers में नहीं कर सकते हैं। 
  5.  Identifiers किसी भी लंबाई का हो सकता है।

Python keywords:

Keywords पाइथन में आरक्षित शब्द (reserved words) है। हम इनका उपयोग variable का नाम, function का नाम रखने या किसी भी identifier में नहीं कर सकते। 

उनका उपयोग वाक्य रचना और प्रोग्राम में संरचनात्मक अंग को परिभाषित करने के लिए किया जाता है। Keywords संवेदनशील (case sensetive) होते है। मतलब उन्ही जैसे का वैसा लिखा जाता है। अगर keyword में कैपिटल लेटर का स्मॉल लेटर भी हो गया तो interpreter त्रुटि दर्शाता है।

True, False और None यह तीन keywords हमेशा uppercase में लिखे जाते है और बाकी सारे keywords को lowercase में लिखते है।


Following is the list of some python keywords:

 None    True     False    if   
 else     elif      break  continue  
 class    and     for       as  
 assert   except   global    def  
 del      and     finally    from  
 import   pass    lambda   in  
 is       while    or        not  
 raise    return   try       await  
यह python के आरक्षित शब्द है और उन्हें जैसे का वैसा लिखा जाता है। 

लेबल:

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

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

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

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