Thuta Learning
ရှာဖွေရန်
BasicProgrammingbeginner

Python Comments

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

🐍 Lesson 4: Python Comments

1. Comment ဆိုတာဘာလဲ?

မြန်မာ → Comment ဆိုတာ Python code ထဲမှာ မှတ်ချက်အနေနဲ့ရေးထားတဲ့ စာကြောင်း ဖြစ်ပြီး Python က အလုပ်မလုပ်ဘဲ လွှဲချသွားတယ်။

English → A comment is a line in the code that is ignored by Python, used for notes or explanations.

2. Comment အမျိုးအစားများ

TypeSyntaxအသုံးပြုပုံ
Single-line# ဖြင့်စသည်တစ်ကြောင်းတည်း comment
Multi-line"""..."""စာကြောင်းများစွာ comment
Docstring"""..."""Function/Class documentation

3. Comment သုံးရတဲ့ အကြောင်းအရင်း

  • 📝 Code ကို နားလည်လွယ်အောင် ရှင်းပြဖို့
  • 🕒 နောက်ပိုင်း ပြန်ဖတ်တဲ့အခါ အလွယ်တကူ သတိရဖို့
  • 🚫 အချိန်ပိုင်းအတွက် code တစ်ပိုင်းကို disable လုပ်ဖို့

4. အကျဉ်းချုပ်

# → Single-line comment

"""...""" → Multi-line / Docstring

✅ Comment တွေက code ကို နားလည်လွယ်အောင် လုပ်ပေးပြီး documentation အတွက် အရေးကြီး

python
# ===== 1. Single-line Comment =====
# ဒီလိုရေးရင် comment ဖြစ်တယ်
print("Hello")  # ဒီလို inline comment လည်း ရ

# ===== 2. Multi-line Comment =====
"""
ဒီနေရာမှာ
စာကြောင်းများစွာ
comment အနေနဲ့ရေးနိုင်တယ်
"""
print("Hello World")

# ===== 3. Docstring Example =====
def greet(name):
    """
    ဒီ function က နာမည်ထည့်ပြီး Hello ပြန်ပေးမယ်
    
    Parameters:
        name (str): လူရဲ့နာမည်
    
    Returns:
        str: Hello message
    """
    return f"Hello {name}"

print(greet("Sai"))

# ===== 4. Temporarily Disable Code =====
# x = 10  # ဒီ code ကို အချိန်ပိုင်း disable လုပ်ထားတယ်
y = 20
print(f"Y value: {y}")
You should see
Hello Hello World Hello Sai Y value: 20
Python Comments | Thuta Learning