Setup & Installation
Python ဆိုတာ ဘာ?
Section titled “Python ဆိုတာ ဘာ?”မစတင်ခင် Python ကို ဘာကြောင့် လေ့လာသင့်သလဲ ဆိုတာ တစ်ခွန်းနဲ့ ရှင်းပါတယ် — Python ဟာ လက်ရှိ ကမ္ဘာမှာ အသုံးအများဆုံး Programming Language တစ်ခုဖြစ်ပြီး Web, AI, Data Science, Automation တွေမှာ ရေသောက်မြစ်လို သုံးနေကြပါတယ်။
အဆင့် ၁ — Python တပ်ဆင်ခြင်း
Section titled “အဆင့် ၁ — Python တပ်ဆင်ခြင်း”python.org ဝဘ်ဆိုဒ်ကနေ Python ကို အခမဲ့ Download ပြုလုပ်နိုင်ပါတယ်။
https://python.org/downloads“Download Python 3.x.x” ဆိုတဲ့ ခလုတ်ကြီးကို နှိပ်ပြီး Installer ကို Download ပြုလုပ်ပါ။
Python မှန်မှန်ကန်ကန် တပ်ဆင်ပြီးလားဆိုတာ စစ်ဆေးနည်း:
Terminal (Windows မှာ Command Prompt သို့မဟုတ် PowerShell) ကို ဖွင့်ပြီး အောက်ပါ Command ကို ရိုက်ထည့်ပါ:
python --versionPython 3.12.0ဒီလို Python version number ပြပေးရင် မှန်ကန်စွာ တပ်ဆင်ပြီးပါပြီ။
အဆင့် ၂ — VS Code တပ်ဆင်ခြင်း
Section titled “အဆင့် ၂ — VS Code တပ်ဆင်ခြင်း”VS Code (Visual Studio Code) ဆိုတာ Microsoft ဖန်တီးထားတဲ့ Code Editor တစ်ခုဖြစ်ပြီး Python ရေးဖို့ အသင့်တော်ဆုံး Editor ပါ။ Code တွေ Highlight ပြပေးတာ၊ Error တွေ ချက်ချင်းညွှန်ပြတာ၊ Terminal ပါ built-in ထည့်ပေးထားတာ တွေ ကြောင့် Beginner တွေ အတွက် အလွန် ကောင်းမွန်ပါတယ်။
https://code.visualstudio.com- VS Code ကို Download ပြုလုပ်ပြီး Install လုပ်ပါ
- VS Code ကို ဖွင့်ပါ
- ဘယ်ဘက် Sidebar မှာ Extensions Icon (⊞) ကို နှိပ်ပါ
- Search Box မှာ
Pythonလို့ ရိုက်ပါ - Microsoft ရဲ့ Python Extension ကို
Installနှိပ်ပါ
အဆင့် ၃ — ပထမဆုံး Python Program ရေးခြင်း
Section titled “အဆင့် ၃ — ပထမဆုံး Python Program ရေးခြင်း”Folder ဖွင့်ခြင်း
Section titled “Folder ဖွင့်ခြင်း”VS Code မှာ File → Open Folder ကနေ ကိုယ်ရဲ့ Projects Folder ကို ဖွင့်ပါ (ဥပမာ Desktop/my-python-projects)။
File အသစ် ဖန်တီးခြင်း
Section titled “File အသစ် ဖန်တီးခြင်း”Folder မှာ File အသစ် ဖန်တီးပြီး hello.py လို့ အမည်ပေးပါ (.py Extension ကို မမေ့ပါနဲ့ — Python ဖိုင် ဆိုတာ ဒါနဲ့ သိတာပါ)။
Code ရေးခြင်း
Section titled “Code ရေးခြင်း”print("မင်္ဂလာပါ, Python!")print("ကျွန်တော်/မ ပထမဆုံး Program ကို ရေးနိုင်ခဲ့ပါပြီ!")Program Run ခြင်း
Section titled “Program Run ခြင်း”VS Code Terminal ကိုဖွင့်ပါ (View → Terminal) ပြီး:
python hello.pyဒီလို ပြပေးရမည်:
မင်္ဂလာပါ, Python!ကျွန်တော်/မ ပထမဆုံး Program ကို ရေးနိုင်ခဲ့ပါပြီ!ဒါဆိုရင် Python လေ့လာဖို့ ပြင်ဆင်မှု ပြည့်စုံသွားပါပြီ!
Python REPL — ချက်ချင်း စမ်းသပ်နိုင်သော Scratchpad
Section titled “Python REPL — ချက်ချင်း စမ်းသပ်နိုင်သော Scratchpad”Terminal မှာ python လို့ ရိုက်ပြီး Enter နှိပ်လိုက်ရင် Python REPL (Read-Eval-Print Loop) ထဲ ရောက်သွားပါမယ်။ REPL ဆိုတာ Code တစ်ကြောင်းကို ချက်ချင်း Run ကြည့်လို့ ရတဲ့ ပုံစံပါ — Calculator တစ်ခုနဲ့ တူပါတယ်။
>>> 2 + 24>>> print("မင်္ဂလာပါ")မင်္ဂလာပါ>>> "python".upper()'PYTHON'>>> exit()>>> ကို မြင်ရရင် REPL ထဲ ရောက်နေတာပါ။ ထွက်ဖို့ exit() လို့ ရိုက်ပါ။
Error တွေ တွေ့ရင်
Section titled “Error တွေ တွေ့ရင်”Setup လုပ်တာနဲ့ပတ်သက်ပြီး အဖြစ်များတဲ့ Error တွေ:
| Error | အဓိပ္ပာယ် | ဖြေရှင်းနည်း |
|---|---|---|
python is not recognized | PATH မထည့်ဘဲ Install လုပ်ထား | Python ကို Uninstall ပြီး “Add to PATH” check ထားပြီး ပြန် Install |
SyntaxError | Code ရေးပုံ မှားနေ | Error message ရဲ့ line number ကြည့်ပြီး စစ်ဆေးပါ |
| File မတွေ့ | Terminal folder မှားနေ | hello.py ရှိတဲ့ Folder ထဲ Terminal ရောက်နေရမည် |