Python · Chapter 2.0 · Start Here level

Start Here: What is a Program? (Hello + Your First Error)

शुरुआत: प्रोग्राम क्या है? (Hello + आपकी पहली Error)

A program is a list of instructions the computer follows from top to bottom, one line at a time. Python is famous because it reads almost like English. The black box under the editor is the Terminal / Console — whatever your program prints appears there. And errors are normal: if you misspell a word, Python stops and tells you the line number. Read the error, fix that line, run again. Every expert does this 100 times a day!

प्रोग्राम निर्देशों की एक लिस्ट है जिसे कंप्यूटर ऊपर से नीचे, एक-एक लाइन करके मानता है। Python इसलिए मशहूर है क्योंकि यह लगभग अंग्रेज़ी जैसी पढ़ी जाती है। एडिटर के नीचे वाला काला डिब्बा Terminal / Console है — आपका प्रोग्राम जो भी print करेगा, वहीं दिखेगा। और errors आना नॉर्मल है: स्पेलिंग गलत होने पर Python रुककर लाइन नंबर बता देता है। Error पढ़ो, वह लाइन ठीक करो, फिर चलाओ। हर एक्सपर्ट दिन में 100 बार यही करता है!

In the classroom you can run and edit this code in your browser, get hints and mark the chapter as done. क्लास में यह code ब्राउज़र में चलाकर बदल सकते हो।

Words and symbols in this chapter

print("...")
Shows the text inside the quotes on the console.
कोट्स के अंदर का टेक्स्ट console पर दिखाता है।
" " (quotes)
Text must be inside quotes, otherwise Python thinks it is a name.
टेक्स्ट कोट्स के अंदर होना चाहिए, वरना Python उसे कोई नाम समझेगा।
# comment
A note for humans; Python skips everything after #.
इंसानों के लिए नोट; # के बाद का सब Python छोड़ देता है।
Error + Line number
Python tells you WHICH line is wrong and WHAT kind of mistake it is.
Python बताता है कि कौन-सी लाइन गलत है और गलती किस तरह की है।

Ready example

# Mera pehla Python program
print("Namaste Duniya!")
print("Main Python seekh raha hun")
print(2 + 3)

What you will see: Look at the Terminal: each print shows one line, in order from top to bottom.

Terminal देखो: हर print ऊपर से नीचे क्रम में एक लाइन दिखाता है।

Line by line

# Mera pehla Python program
A comment — Python ignores it.
Comment — Python इसे नज़रअंदाज़ करता है।
print("Namaste Duniya!")
Prints the greeting.
नमस्ते वाला संदेश छापता है।
print(2 + 3)
Numbers need no quotes; Python calculates and prints 5.
नंबर को कोट्स नहीं चाहिए; Python जोड़कर 5 छापता है।

Common mistake

✗ Wrong

print(Namaste)

✓ Right

print("Namaste")

Without quotes Python searches for a variable named Namaste and gives NameError.

कोट्स के बिना Python Namaste नाम का variable ढूँढता है और NameError देता है।

Your task

Fix the error (Print → print), put your name in the message, and add one more print() with your city.

Error ठीक करो (Print → print), संदेश में अपना नाम लिखो, और अपने शहर वाला एक और print() जोड़ो।

  1. Run once and read the red error: NameError on line 2 — Print with capital P is unknown.
    एक बार Run करो और लाल error पढ़ो: लाइन 2 पर NameError — कैपिटल P वाला Print Python नहीं जानता।
  2. Change Print to print and replace ... with your name.
    Print को print करो और ... की जगह अपना नाम लिखो।
  3. Add a new line: print("Mera shehar: Jaipur") (your city) and Run.
    नई लाइन जोड़ो: print("Mera shehar: Jaipur") (अपना शहर) और Run करो।
Starter code for the task
# Neeche ki line mein GALTI hai (P capital hai). Use theek karo:
Print("Mera naam ... hai")
# TODO: ek aur print() likho jo aapke shehar ka naam dikhaye

Do this task in the classroom: your code is checked automatically and you get hints if something is missing.

Recap

Quick quiz

What does Python do with a line that starts with #?

# से शुरू होने वाली लाइन का Python क्या करता है?

  1. Prints it
  2. Ignores it (it is a comment)
  3. Deletes the program
  4. Makes it bold
Show the answer

Answer: B (Ignores it (it is a comment))

# starts a comment — notes for humans that Python skips.

# comment शुरू करता है — इंसानों के लिए नोट जिसे Python छोड़ देता है।

More practice at this level

Solve them in the Practice Zone, where each answer is checked automatically and two hints are available.