Your First Python Program — print, Comments, Zen

প্রথম Python প্রোগ্রাম — print, মন্তব্য, Zen

Read: ~25 min Beginner 5 practice problems Live code runner

1. Hello, World — and Why It Matters

Every Python programmer's journey starts with print("Hello, World!"). It looks trivial, but hidden in that single line are three things you will use every day: a function call, a string literal, and an expression statement. Understanding those ideas well now will save you time for years.

প্রতিটি Python programmer-এর যাত্রা শুরু হয় print("Hello, World!") দিয়ে। দেখতে তুচ্ছ মনে হলেও, এই এক লাইনে তিনটি বিষয় লুকিয়ে আছে — function call, string literal, এবং expression statement — যা প্রতিদিন কাজে লাগবে।
hello.py
print("Hello, World!")
print("হ্যালো বিশ্ব!")

2. The print() Function in Detail

print() accepts any number of arguments and displays them on standard output (your terminal), separated by spaces and followed by a newline. Two keyword arguments give you control: sep (separator) and end (ending).

print_demo.py
# Multiple arguments — separated by a space by default
print("Dhaka", "Chattogram", "Sylhet")

# Change the separator
print("Dhaka", "Chattogram", "Sylhet", sep=" | ")

# Change the line-ending — default is '\n' (newline)
print("Loading", end="... ")
print("done")

# Print a number and a string together
print("Year:", 2026)
print() যতগুলো argument দেন, সবগুলোকে space দিয়ে যোগ করে newline সহ দেখায়। sep দিয়ে separator, end দিয়ে শেষের অক্ষর পরিবর্তন করা যায়।

3. Comments — Notes to Your Future Self

A comment is text Python ignores. Its only purpose is to help humans understand the code. Python has two kinds: single-line (starting with #) and multi-line (a triple-quoted string used as a standalone line).

comments.py
# This is a single-line comment. Python ignores it.
price = 250      # you can also put a comment at the end of a line

"""
This is a multi-line string.
When placed on its own line, it acts as a block comment.
Useful for temporarily disabling a chunk of code.
"""

print("Price is", price)
Good vs bad comments Good comments explain why, not what. # increment i by 1 is noise — the code already says that. # skip Fridays because the API is closed — that's valuable.

ভালো মন্তব্য কেন বোঝায়, কী নয়। # i-কে ১ বাড়াও অপ্রয়োজনীয়। # শুক্রবার বাদ — API বন্ধ থাকে — মূল্যবান।

4. Docstrings — Documentation That Lives With the Code

A docstring is a triple-quoted string placed as the first line of a module, class, or function. Tools like help(), IDE tooltips, and documentation generators read docstrings automatically. Unlike comments, docstrings are officially part of the program — they are attached to the object at runtime.

docstrings.py
"""greetings.py — friendly greetings for the ABCL course."""

def greet(name):
    """Return a friendly greeting for the given name.

    Parameters
    ----------
    name : str
        The person's name.

    Returns
    -------
    str
        A complete greeting sentence.
    """
    return f"Hello, {name}! Welcome to Python."

print(greet("Ayesha"))
print(greet.__doc__[:50])   # docstring is accessible at runtime

5. The Zen of Python

In 2004, Tim Peters wrote a short poem of 19 aphorisms that capture Python's philosophy. Type import this in any Python REPL and Python will print it for you. The Zen is not law — it is taste.

zen.py
import this   # prints the Zen of Python
AphorismWhat it meansবাংলায়
Beautiful is better than ugly.Clean code beats clever tricks.সুন্দর কোড কুৎসিত কোডের চেয়ে ভালো।
Explicit is better than implicit.Say what you mean; no magic.স্পষ্টভাবে বলুন, লুকানো জাদু নয়।
Simple is better than complex.Choose the simplest design that works.সহজ সমাধান জটিলের চেয়ে ভালো।
Readability counts.Code is read more than written.কোড লেখার চেয়ে পড়া বেশি হয়।
There should be one obvious way to do it.Pythonic = one right path.একটি কাজের জন্য একটাই স্পষ্ট উপায়।

6. Common First-Day Mistakes

✗ Mistakes (সাধারণ ভুল)

  • Print("hi") — capital P → NameError
  • print "hi" — Python 2 syntax
  • Missing colon: if x == 3
  • Mixing tabs and spaces
  • "it's" inside single quotes

✓ Fixes (সঠিক)

  • print("hi")
  • Use Python 3 only
  • if x == 3:
  • Use 4 spaces everywhere
  • "it's" in double quotes

7. Vocabulary (শব্দভাণ্ডার)

TermMeaningবাংলায়
StatementA complete instruction Python can execute.একটি সম্পূর্ণ নির্দেশ।
ExpressionSomething that evaluates to a value.যা একটি মানে রূপান্তরিত হয়।
Function callRunning a function with arguments, e.g., print(x).function চালানো, যেমন print(x)।
CommentText the interpreter ignores.interpreter যা উপেক্ষা করে।
DocstringTriple-quoted string at the start of a function/module.function/module-এর শুরুতে ট্রিপল-কোট string।
IndentationLeading whitespace that defines code blocks in Python.Python-এ block তৈরি করে সামনের whitespace।

8. Practice Problems

  1. Use a single print() call to print "Python", "is", "fun" separated by hyphens.
    একটি মাত্র print() দিয়ে "Python", "is", "fun" হাইফেন দিয়ে আলাদা করে প্রিন্ট করুন।
    ✨ Show Answer (উত্তর দেখুন)
    a1.py
    print("Python", "is", "fun", sep="-")
  2. Write a program that prints "Loading..." then "done!" on the same line, with a space between them.
    এমন প্রোগ্রাম লিখুন যা একই লাইনে "Loading..." এবং "done!" প্রিন্ট করবে।
    ✨ Show Answer (উত্তর দেখুন)
    a2.py
    print("Loading...", end=" ")
    print("done!")
  3. Write a function area_of_circle(r) with a clear docstring. It should return π·r².
    একটি area_of_circle(r) function লিখুন, যার docstring স্পষ্ট হবে। এটি π·r² return করবে।
    ✨ Show Answer (উত্তর দেখুন)
    a3.py
    import math
    
    def area_of_circle(r):
        """Return the area of a circle with radius r.
    
        r must be a non-negative real number.
        """
        return math.pi * r * r
    
    print(area_of_circle(5))
  4. Explain in your own words why docstrings are better than ordinary comments for functions.
    নিজের ভাষায় ব্যাখ্যা করুন — function-এর জন্য docstring কেন সাধারণ comment-এর চেয়ে ভালো।
    ✨ Show Answer (উত্তর দেখুন)

    Answer: Comments vanish at parse time — they exist only in the source file. Docstrings, by contrast, are real string objects attached to the function and accessible at runtime via func.__doc__. Tools like help(), Sphinx, VS Code tooltips, and Jupyter all read docstrings to show documentation. One string does double duty — documentation for humans and machine-readable help.

    Comment শুধু source file-এ থাকে। docstring একটি বাস্তব string object — runtime-এ func.__doc__ দিয়ে পাওয়া যায়। help(), Sphinx, VS Code — সব এটি থেকেই documentation দেখায়।

  5. Write a three-line program: the first two lines are comments explaining what the program does, the third prints your name.
    তিন লাইনের প্রোগ্রাম লিখুন — প্রথম দুই লাইন comment, তৃতীয় লাইন আপনার নাম প্রিন্ট করবে।
    ✨ Show Answer (উত্তর দেখুন)
    a5.py
    # name_printer.py
    # Prints the author's name — a tiny first Python program.
    print("Nadia Rahman")

Summary — Module 04

print() is a function — pass it any values, and tune it with sep and end. Comments (#) are for humans and disappear at parse time; docstrings (triple-quoted) live on the object and drive tools like help(). Python's philosophy is captured in the Zen of Python: simple, readable, explicit code wins. Watch out for capitalization, colons, and tab/space mixing — the most common first-day errors.

print() একটি function, sep ও end দিয়ে নিয়ন্ত্রণ করুন। # শুধু মানুষের জন্য; docstring object-এর সাথে থাকে, help()-এ দেখা যায়। Python-এর দর্শন: সহজ, পাঠযোগ্য, স্পষ্ট।

Next Module → Data Types — int, float, str, bool, None — Python-এর মৌলিক ডেটা।