First Python Program (Hello World)
Programming Language အသစ်တစ်ခုကို စတင်လေ့လာရာတွင် ရိုးရာအစဉ်အလာအရ Hello World Program ကို ပထမဆုံး ရေးသားလေ့ရှိကြသည်။ ဤသင်ခန်းစာတွင် Python File တစ်ခု ဖန်တီးခြင်း၊ print() Function ကို အသုံးပြုခြင်း၊ Program ကို Run ပြုလုပ်ခြင်းနှင့် Output ကို နားလည်ခြင်းတို့ကို လေ့လာသွားပါမည်။
1. Hello World ဆိုတာဘာလဲ?
Programming ကို စတင်လေ့လာသူတိုင်း ရေးလေ့ရှိသော အရိုးရှင်းဆုံး Program ကို Hello World Program ဟု ခေါ်ပါသည်။
ဒီ Program ၏ ရည်ရွယ်ချက်မှာ Language အသစ်တစ်ခုကို မှန်ကန်စွာ Install လုပ်ပြီး Run လုပ်နိုင်ကြောင်း စစ်ဆေးရန် ဖြစ်ပါသည်။
2. Python File တစ်ခု ဖန်တီးခြင်း
Visual Studio Code ကို ဖွင့်ပြီး Folder အသစ်တစ်ခု ဖန်တီးပါ။
ထို့နောက် File အသစ်တစ်ခုကို
hello.py
ဟု အမည်ပေးပါ။
Python Program များ၏ File Extension သည် .py ဖြစ်ပါသည်။
3. ပထမဆုံး Python Program
hello.py ထဲတွင် အောက်ပါ Code ကို ရေးပါ။
print("Hello World")
4. Program ကို Run ပြုလုပ်ခြင်း
Terminal ကို ဖွင့်ပြီး အောက်ပါ Command ကို ရိုက်ထည့်ပါ။
python hello.py
Output
Hello World
Terminal ပေါ်တွင် Hello World ပေါ်လာပါက သင့် Python Program ကို အောင်မြင်စွာ Run လုပ်နိုင်ပြီ ဖြစ်ပါသည်။
5. print() Function ဆိုတာဘာလဲ?
print() သည် Python တွင် Screen ပေါ်သို့ စာသား၊ ဂဏန်းနှင့် Result များကို ဖော်ပြရန် အသုံးပြုသော Built-in Function ဖြစ်ပါသည်။
ဥပမာ -
print("Welcome to Python")
print("Programming is fun!")
Output
Welcome to Python
Programming is fun!
print() ကို အသုံးပြု၍ Program ၏ Result များကို ကြည့်ရှုနိုင်ပါသည်။
6. String ဆိုတာဘာလဲ?
Double Quote (" ") သို့မဟုတ် Single Quote (' ') အတွင်း ရေးထားသော စာသားများကို String ဟု ခေါ်ပါသည်။
ဥပမာ -
print("Python")
print("Hello")
print("Myanmar")
အားလုံးသည် String များ ဖြစ်ပါသည်။
7. print() ကို အကြိမ်များစွာ အသုံးပြုခြင်း
print("Hello")
print("My Name is Aung Aung")
print("I am learning Python.")
Output
Hello
My Name is Aung Aung
I am learning Python.
print() တစ်ကြောင်းချင်းစီသည် Output အသစ်တစ်ကြောင်းကို ဖော်ပြပေးပါသည်။
8. Beginner များ အများဆုံးလုပ်မိသော အမှားများ
Quotation မပိတ်ခြင်း
print("Hello World)
❌ Error ဖြစ်မည်။
မှန်ကန်သော ရေးနည်း
print("Hello World")
Bracket မပိတ်ခြင်း
print("Python"
❌ Error ဖြစ်မည်။
မှန်ကန်သော ရေးနည်း
print("Python")
Print နှင့် print မတူခြင်း
Python သည် Case Sensitive ဖြစ်ပါသည်။
Print("Hello")
❌ Error
print("Hello")
✅ မှန်ကန်သည်။
ဒီသင်ခန်းစာမှ သိထားသင့်သော အချက်များ
Hello World သည် Programming ၏ ပထမဆုံး Program ဖြစ်သည်။
Python File များ၏ Extension သည် .py ဖြစ်သည်။
print() Function ကို အသုံးပြု၍ Output ကို ဖော်ပြနိုင်သည်။
String များကို Quote (" " သို့မဟုတ် ' ') အတွင်း ရေးသားရသည်။
Python သည် Case Sensitive Programming Language ဖြစ်သည်။
လေ့ကျင့်ခန်း
(၁) "Welcome to Python Programming" ကို Screen ပေါ်တွင် ဖော်ပြပါ။
(၂) print() ကို (၃) ကြောင်း အသုံးပြုပြီး မိမိအကြောင်း အောက်ပါအတိုင်း ဖော်ပြပါ။
My Name is ...
I live in ...
I am learning Python.
(၃) Print("Hello") နှင့် print("Hello") တို့၏ ကွာခြားချက်ကို ကိုယ်တိုင် စမ်းသပ်ကြည့်ပါ။