🟢 Beginner  ·  Lesson 03

पहला Python Program: Hello World

पहला Program

हर programmer का सफ़र "Hello, World!" print करने से शुरू होता है। यह साबित करता है कि आपका Python setup चल रहा है और सबसे ज़्यादा use होने वाला function सिखाता है: print()

Program 1: Hello World

Python – hello.py
print("Hello, World!")
Hello, World!

इसे hello.py के रूप में save करके run करें। print() brackets के अंदर जो भी हो उसे screen पर भेजता है।

Program 2: कई Lines Print करें

Python – lines.py
print("Welcome to Python")
print("This is line 2")
print("Learning is fun")
Welcome to Python This is line 2 Learning is fun

हर print() अपने आप नई line पर जाता है। एक ही string में \n से भी line तोड़ सकते हैं।

Program 3: print() Tricks (sep और end)

Python – print_tricks.py
# sep items के बीच separator बदलता है
print("2026", "06", "01", sep="-")

# end बदलता है कि बाद में क्या आए (default newline)
print("Loading", end="...")
print("Done")
2026-06-01 Loading...Done
  • sep="-" items के बीच space की जगह dash लगाता है।
  • end="..." line टूटने से रोककर "..." जोड़ता है।
  • इसलिए अगला print उसी line पर continue होता है।

print() कैसे काम करता है

  • Comma से अलग किए items default रूप से बीच में space के साथ print होते हैं।
  • sep control करता है कि items के बीच क्या जाए।
  • end control करता है कि पूरी line के बाद क्या जाए (default \n)।

सामान्य गलतियाँ

  • Quotes भूलना: print(Hello) NameError देता है।
  • Word के smart/curly quotes use करना straight quotes की जगह।
  • गलत file extension — .py में save करें।

Practice Tasks

  1. end use करके "Hello" और अपना नाम एक ही line पर print करें।
  2. sep="/" से आज की date DD/MM/YYYY में print करें।
  3. \n से एक print() में 3-line कविता print करें।

सारांश

  • print() screen पर output दिखाता है।
  • हर print default रूप से नई line शुरू करता है।
  • sep = items के बीच separator; end = line के बाद क्या आए।
← Back to Python Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 लाइव कोड एडिटर

इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.