Basic Syntax of Python in Hindi

Python का syntax बहुत ही सरल और readable होता है। इस language में indentation का बहुत महत्व है, और यह syntax को बहुत clean बनाता है। यहां पाइथन के कुछ मुख्य syntax दिए गए हैं:

1. प्रिंट स्टेटमेंट (Print Statement)

पाइथन में print() function का उपयोग output दिखाने के लिए किया जाता है।

उदाहरण:

print("Hello, World!")

यह output में “Hello, World!” दिखाएगा।

2. Variables

पाइथन में variables को declare करने के लिए किसी भी विशेष keyword की जरूरत नहीं होती। सीधे variable name और value को लिखने से variable बन जाता है।

उदाहरण:

x = 10
name = "Yugal"

यहां x में 10 और name में “Yugal” स्टोर हो गया।

3. Data Types

पाइथन में कुछ सामान्य data types होते हैं, जैसे:

  • int – integer numbers
  • float – decimal numbers
  • str – text या strings
  • bool – Boolean values (True, False)

उदाहरण:

a = 5       # int

b = 3.14    # float

c = "Hello" # string

d = True    # boolean

4. Functions

पाइथन में functions को def कीवर्ड का उपयोग करके define किया जाता है।

उदाहरण:

def greet(name):

    print("Hello, " + name + "!")

greet("Yugal")

यहां greet function एक नाम input लेता है और उसे print करता है।

5. List, Tuple, and Dictionary

List

fruits = ["apple", "banana", "cherry"]

Tuple

coordinates = (4, 5)

Dictionary

student = {"name": "Yugal", "age": 25}

6. Indentation

पाइथन में indentation बहुत जरूरी है क्योंकि यह blocks को define करता है। किसी भी block की शुरुआत एक समान space से होनी चाहिए। गलत indentation syntax error देता है।

if age >= 18:

    print("You are eligible to vote.")   # सही इंडेंटेशन

  # print("This will cause an error")   # गलत इंडेंटेशन

7. Comments

पाइथन में comments कोड में notes जोड़ने के लिए उपयोग किए जाते हैं, जो कि program के execution को प्रभावित नहीं करते। Comments को # symbol से शुरू किया जाता है।

# This is Comment

Multi-Line Comments के लिए ”’ या “”” का उपयोग किया जा सकता है:

'''

This is

Multi-Line

Comment

'''

Summary (सारांश)

“Basic Syntax of Python in Hindi” लेख पाइथन सीखने वाले beginners के लिए एकदम सही शुरुआत है। इसमें Python की आसान और readable syntax को सरल हिंदी में समझाया गया है। आप सीखेंगे कि कैसे print() function से output दिखाएँ, variables बिना किसी keyword के बनाएँ, और int, float, str, bool जैसे data types का उपयोग करें। साथ ही, def keyword से functions define करना, List, Tuple, और Dictionary बनाना भी समझाया गया है। इसमें indentation का महत्व बताया गया है, जो Python में blocks define करता है और syntax error से बचाता है। Comments के जरिए कोड में notes जोड़ना भी सिखाया गया है। छात्र इस article से क्या सीखेंगे:

  • Python के basic syntax को step-by-step समझेंगे।
  • Print, variables, data types और functions का practical उपयोग सीखेंगे।
  • List, Tuple, Dictionary की basics clear होंगी।
  • Indentation के नियम और सही तरीका जानेंगे।
Exam preparation में मदद: यह article interview और theory exams के लिए महत्वपूर्ण topics जैसे syntax rules, data types और functions को कवर करता है। छात्र इससे Python programming की नींव मजबूत कर सकते हैं और coding questions को आसानी से हल कर सकते हैं।

Leave a Comment