ရိုးရိုးလေး ရှင်းပြမယ်
ရိုးရိုးလေး ရှင်းရရင်
Python ဆိုတာ ကွန်ပျူတာကို အလုပ်ခိုင်းဖို့ ရေးတဲ့ programming language တစ်ခုပါ။ သူ့ code က အင်္ဂလိပ်စာ ဖတ်ရသလို ရှင်းလင်းလို့ programming စလေ့လာသူတွေ အများဆုံး ရွေးကြတဲ့ language တစ်ခု ဖြစ်ပါတယ်။ ဒါပေမယ့် ကလေးကစားစရာ မဟုတ်ပါဘူး — ကြီးမားတဲ့ website backend တွေ၊ ဒေတာ သိပ္ပံပညာရှင်တွေရဲ့ analysis notebook တွေ၊ AI model training script တွေကို Python နဲ့ ရေးထားကြပါတယ်။
ဒီ course က zero ကနေ စပါတယ်။ ပထမ lesson တွေမှာ value တွေကို သိမ်းတာ၊ ဆုံးဖြတ်ချက်ချတာ၊ အလုပ်တွေကို ထပ်ခါထပ်ခါ လုပ်တာကို သင်ပြီး နောက်ပိုင်းမှာ file, database, web API နဲ့ project အစစ်တွေ တည်ဆောက်တဲ့အထိ တစ်ဆင့်ချင်း တက်သွားပါမယ်။
Problem → Why → Solution
ပြဿနာ: စနစ်မကျတဲ့ လေ့လာနည်း
Python စလေ့လာသူ အများစုဟာ video တစ်ခုမှာ Django website၊ နောက်တစ်ခုမှာ pandas chart ကို ကြည့်ပြီး code ကို copy ကူးကြပါတယ်။ ပထမ error မှာတင် ရပ်သွားပါတယ် — NameError ဆိုတာ ဘာလဲ၊ indentation ဘာလို့ အရေးကြီးလဲ မသိလို့ပါ။ အောက်က code က beginner တစ်ယောက် ရေးမိတဲ့ ပုံစံပါ။ ပထမ line က အလုပ်လုပ်ပြီး ဒုတိယ line မှာ crash ဖြစ်ပါတယ်။
print("Starting my program")
Print("Total:", 2 + 3) # NameError: name 'Print' is not defined
print("Done") # never runsဘာကြောင့် ရပ်သွားတာလဲ
Python က file ကို အပေါ်ကနေ အောက်ကို တစ်ကြောင်းချင်း run ပါတယ်။ Print (P အကြီး) ဆိုတဲ့ နာမည် မရှိလို့ line 2 မှာ error တက်ပြီး program ရပ်သွားတာမို့ "Done" ကို ဘယ်တော့မှ print မထုတ်ပါဘူး။ ဒီလို အခြေခံ စည်းမျဉ်းတွေကို အစီအစဉ်တကျ သင်ထားရင် error message ကို ဖတ်ပြီး ကိုယ်တိုင် ပြင်နိုင်ပါတယ်၊ ဒါကြောင့် ဒီ course က အခြေခံကနေ အစီအစဉ်လိုက် စထားတာပါ။
Core concept: Python ဆိုတာ ဘာလဲ၊ course ကို ဘယ်လို စီထားလဲ
Python program တစ်ခုဆိုတာ .py နဲ့ ဆုံးတဲ့ text file တစ်ခုပါ။ python ဆိုတဲ့ interpreter program က အဲဒီ file ကို ဖတ်ပြီး statement တွေကို အပေါ်ကနေ အောက်ကို run ပါတယ်။ Compile လုပ်ပြီး .exe file ထုတ်စရာ မလိုလို့ code ပြင်တာနဲ့ ချက်ချင်း ပြန် run ကြည့်လို့ ရပါတယ်။ ဒီ course က Python 3 ကို သင်ပါတယ် — Python 2 ကို 2020 ကတည်းက support ရပ်လိုက်ပြီမို့ အင်တာနက်ပေါ်မှာ print "hi" (ကွင်းမပါ) လို code တွေ့ရင် ခေတ်မမီတော့တဲ့ Python 2 code လို့ မှတ်ပါ။
Python ကို သုံးရတာ အဆင်ပြေတာ အပိုင်း သုံးပိုင်းကြောင့်ပါ။ ပထမက language ကိုယ်တိုင် — variable, if, for, function, class လို grammar ပါ။ ဒုတိယက standard library — math, json, sqlite3, pathlib လို Python နဲ့အတူ ပါလာပြီးသား module တွေမို့ import လုပ်ရုံပါပဲ။ တတိယက third-party package တွေ — NumPy, pandas, Django, requests လိုမျိုး တခြားလူတွေ ရေးထားတာမို့ pip နဲ့ သီးသန့် install လုပ်ရပြီး version လည်း သီးသန့် ရှိပါတယ်။ Error တစ်ခု တွေ့ရင် ဘယ်အပိုင်းက လာတာလဲ ခွဲသိတာက ပြဿနာ တစ်ဝက်ကို ဖြေရှင်းပြီးသားပါပဲ။
Course ရဲ့ lesson ၇၀ ကို chapter ငါးခု ခွဲထားပါတယ်။ Basic က အုတ်မြစ်ပါ၊ Intermediate က code ကို စနစ်တကျ ဖွဲ့စည်းပြီး file နဲ့ library တွေနဲ့ ချိတ်တာပါ၊ Advanced က professional developer တွေ နေ့စဉ်သုံးတဲ့ tool တွေပါ။ Projects နဲ့ Exercises ကတော့ သင်ခဲ့သမျှကို ပေါင်းသုံးတဲ့ နေရာပါ။ Chapter တစ်ခုစီက ရှေ့ chapter ပေါ်မှာ အခြေခံထားလို့ အစဉ်လိုက် သွားတာ အကောင်းဆုံးပါ။
| Chapter | Lesson | ဘာတွေ သင်မလဲ |
|---|---|---|
| Basic | 19 | Syntax, comment, variable, data type, string, operator, list, dict, if, loop, function |
| Intermediate | 22 | OOP, exception, debugging, file handling, NumPy, pandas, SciPy, Django |
| Advanced | 22 | Decorator, generator, comprehension, API, JSON, SQLite, testing, venv, pip |
| Projects | 5 | Calculator, to-do list, weather app, web scraper, Flask REST API |
| Exercises | 2 | Basic နဲ့ intermediate topic တွေကို ရောထားတဲ့ practice set နှစ်ခု |
- Code ကို .py file ထဲ ရေး
- python file.py နဲ့ run
- Interpreter က အပေါ်ကနေ အောက် ဖတ်
- print() က output ပြ၊ error ဆို ရပ်
Error တက်တဲ့ line မတိုင်ခင်က output တွေ ပေါ်ပြီးသား ဖြစ်နေတတ်လို့ ဘယ်အထိ အလုပ်လုပ်ခဲ့လဲ ကြည့်ပြီး error နေရာကို ရှာနိုင်ပါတယ်။
အထွေထွေ ပုံစံ: program သေးသေးလေး တစ်ခုရဲ့ ပုံသဏ္ဌာန်
# 1. store values under names
name = value
# 2. compute something new from them
result = name + other_value
# 3. show it
print("label:", result)Program သေးသေးလေး အများစုဟာ အဆင့်သုံးဆင့်ပါ — value ကို နာမည်နဲ့ သိမ်း၊ အဲဒီကနေ value အသစ် တွက်၊ print() နဲ့ ပြ။ print() ကို comma ခြားပြီး argument အများကြီး ပေးရင် တစ်ခုနဲ့တစ်ခုကြား space တစ်ခုစီ ထည့်ပြီး ထုတ်ပေးပါတယ်။
Example: ပထမဆုံး program
ဒီ code ကို first_program.py အဖြစ် save လုပ်ပြီး terminal မှာ python first_program.py (macOS/Linux မှာ python3) နဲ့ run ပါ။ Run မလုပ်ခင် line တစ်ကြောင်းချင်းစီ ဘာ print ထုတ်မလဲ စာရွက်ပေါ်မှာ ကြိုရေးကြည့်ပါ၊ ပြီးမှ တကယ့် output နဲ့ တိုက်ကြည့်ပါ။ ဒီအလေ့အကျင့်ကို lesson တိုင်းမှာ လုပ်ရင် code ဖတ်တဲ့ စွမ်းရည် အရမ်း မြန်မြန် တိုးလာပါတယ်။
# first_program.py - run it with: python first_program.py
course = "Python"
lessons = 70
chapters = ["Basic", "Intermediate", "Advanced", "Projects", "Exercises"]
print(f"Welcome to the {course} course!")
print(f"{lessons} lessons in {len(chapters)} chapters")
print("First chapter:", chapters[0])
print("2 + 3 =", 2 + 3)Code ကို တစ်ပိုင်းချင်း ရှင်းပြမယ်
- Line 1
# first_program.py - run it with: python first_program.py# နဲ့ စတဲ့ line က comment ပါ။ Python က လုံးဝ ကျော်သွားပြီး လူဖတ်ဖို့ သက်သက်ပါ။
- Lines 2-3
lessons = 70= က ညာဘက်က value ကို ဘယ်ဘက်က နာမည်နဲ့ ချိတ်ပါတယ်။ "Python" က quote ထဲမှာမို့ text (str) ဖြစ်ပြီး 70 ကတော့ quote မပါလို့ number (int) ပါ။
- Line 4
chapters = ["Basic", "Intermediate", "Advanced", "Projects", "Exercises"]လေးထောင့်ကွင်း [ ] က list တစ်ခု ဆောက်ပါတယ်၊ value တွေကို အစဉ်လိုက် စုထားတဲ့ စာရင်းပါ။ len(chapters) က item အရေအတွက် 5 ကို ပြန်ပေးပါတယ်။
- Line 6
print(f"Welcome to the {course} course!")Quote ရှေ့က f က f-string ကို ဆိုလိုပါတယ်။ {course} နေရာမှာ variable ရဲ့ value "Python" ဝင်သွားလို့ Welcome to the Python course! ထွက်ပါတယ်။
- Line 8
print("First chapter:", chapters[0])List ရဲ့ position တွေကို 0 ကနေ စရေတွက်ပါတယ်၊ ဒါကြောင့် chapters[0] က ပထမ item "Basic" ပါ။ print() က argument နှစ်ခုကြားမှာ space တစ်ခု ထည့်ပေးပါတယ်။
- Line 9
print("2 + 3 =", 2 + 3)Quote ထဲက "2 + 3 =" က စာသားအတိုင်း ထွက်ပြီး quote မပါတဲ့ 2 + 3 ကိုတော့ အရင် တွက်လို့ 5 ထွက်ပါတယ်။ Quote ရှိ မရှိက value ရဲ့ type ကို ပြောင်းစေပါတယ်။
Welcome to the Python course!
70 lessons in 5 chapters
First chapter: Basic
2 + 3 = 5Lesson တစ်ခုစီကို ဘယ်လို လေ့လာမလဲ
Lesson တိုင်းမှာ အစီအစဉ် တူတူပါ — ရိုးရိုးရှင်းပြချက်၊ ပြဿနာ အစစ်တစ်ခု၊ concept၊ run လို့ရတဲ့ example၊ အဖြစ်များတဲ့ အမှားတွေ၊ mini challenge နဲ့ quiz တိုလေး။ အကျိုးအများဆုံး ရဖို့ အောက်က အဆင့်တွေကို လိုက်လုပ်ပါ။
1. Example ကို ကိုယ်တိုင် ရိုက်ပါ
Copy-paste မလုပ်ဘဲ ရိုက်ရင် colon, ကွင်း, indentation တွေကို လက်က မှတ်မိလာပါတယ်။
2. Output ကို ကြိုခန့်မှန်းပါ
Run မလုပ်ခင် ခန့်မှန်းချက် ရေးထားပါ။ မှားရင် ဘာကို နားလည်မှု လွဲနေလဲ အဲဒီမှာ ပေါ်လာပါတယ်။
3. Value တစ်ခု ပြောင်းကြည့်ပါ
lessons = 70 ကို 7 ပြောင်းတာ၊ chapters[0] ကို chapters[4] ပြောင်းတာလို အသေးအဖွဲ ပြောင်းပြီး ရလဒ်ကို ထပ်ခန့်မှန်းပါ။
4. Challenge ကို solution မကြည့်ခင် ကြိုးစားပါ
ပိတ်မိနေရင် hint ကို အရင်ဖတ်ပါ၊ solution ကို နောက်ဆုံးမှ ကြည့်ပါ။
လက်တွေ့ project တွေမှာ
Real project တွေမှာ ဘယ်လို သုံးလဲ
Web development မှာ Django နဲ့ Flask လို framework တွေနဲ့ website backend နဲ့ API တွေ ရေးကြပါတယ်။ ဒီ course ရဲ့ Intermediate chapter မှာ Django ကို၊ Projects chapter မှာ Flask REST API ကို တကယ် တည်ဆောက်ကြည့်ရပါမယ်။ Data analysis မှာ pandas နဲ့ NumPy က Excel ဖိုင်ကြီးတွေ၊ sales record ထောင်ပေါင်းများစွာကို စက္ကန့်ပိုင်းအတွင်း စစ်ထုတ်ပြီး အနှစ်ချုပ် ထုတ်ပေးပါတယ်။
Automation ကလည်း Python ရဲ့ အားသာချက်ပါ — folder ထဲက file ရာပေါင်းများစွာကို နာမည်ပြောင်းတာ၊ နေ့တိုင်း report ထုတ်တာ၊ website တစ်ခုက data ကို ဆွဲယူတာ (web scraping) တွေကို script တိုလေးနဲ့ လုပ်နိုင်ပါတယ်။ AI နဲ့ machine learning မှာလည်း PyTorch လို library တွေက Python ကို အဓိက interface အဖြစ် သုံးပါတယ်။ Job တစ်ခုခုမှာ Python ကို သုံးတဲ့အခါ ဒီ course ရဲ့ Basic chapter က အရာတွေက နေ့တိုင်း ပါနေမှာပါ။
အမှားများ
အဖြစ်များတဲ့ အမှားတွေ
1. Python 2 tutorial ဟောင်းတွေကို လိုက်တာ
print "Hello" (ကွင်းမပါ) နဲ့ raw_input() လို code တွေက Python 2 ပါ။ Python 3 မှာ ပထမတစ်ခုက SyntaxError ဖြစ်ပြီး raw_input() ကို input() လို့ အမည်ပြောင်းထားပါတယ်။ Tutorial တစ်ခု ဖတ်ရင် print() ကို ကွင်းနဲ့ ရေးထားလား အရင် စစ်ပါ။
2. Basic ကို ကျော်ပြီး framework ကို တန်းစတာ
Django ဒါမှမဟုတ် pandas ကို အရင်စရင် error တစ်ခုချင်းစီက framework ကြောင့်လား၊ Python ကြောင့်လား မခွဲနိုင်ပါဘူး။ Basic chapter ရဲ့ variable, list, dict, loop, function တွေကို အရင် ကျွမ်းထားရင် framework code ကို ဖတ်ရတာ အများကြီး လွယ်သွားပါတယ်။
3. Python နဲ့ ကြီး/သေး ခွဲတာကို မေ့တာ
Print, PRINT နဲ့ print က နာမည် သုံးခု ကွဲပါတယ်။ print ကပဲ built-in function ဖြစ်လို့ ကျန်တာတွေက NameError ပေးပါတယ်။ Python version အသစ်တွေက "Did you mean: 'print'?" လို အကြံပြုချက်ပါ ပြပေးလို့ error message ကို အဆုံးထိ ဖတ်ပါ။
Mini challenge
Mini challenge: ကိုယ့် study plan
Course ကို ဘယ်နှစ်ပတ်နဲ့ ပြီးမလဲ တွက်ပြီး print ထုတ်တဲ့ study_plan.py program တစ်ခု ရေးပါ။
- ကိုယ့်နာမည်၊ lesson စုစုပေါင်း (70) နဲ့ တစ်ပတ်မှာ လုပ်မယ့် lesson အရေအတွက်ကို variable တွေထဲ သိမ်းရမယ်
- Lesson စုစုပေါင်းကို တစ်ပတ်စာနဲ့ စားပြီး ပတ်အရေအတွက်ကို တွက်ရမယ်
- f-string သုံးပြီး အနည်းဆုံး စာကြောင်း သုံးကြောင်း print ထုတ်ရမယ်
# TODO: store your name
# TODO: store the total number of lessons in the course
# TODO: store how many lessons you plan to finish each week
# TODO: weeks = total lessons divided by lessons per week
# TODO: print a greeting that uses your name
# TODO: print the pace, e.g. "Pace: 5 lessons per week"
# TODO: print how many weeks it will takeရလဒ်: Sample value တွေနဲ့ဆိုရင်: Hi Aye, let's learn Python! Pace: 5 lessons per week You will finish all 70 lessons in 14 weeks.
အရိပ်အမြွက် ကြည့်ရန်
/ နဲ့ စားရင် 14.0 လို decimal ရပြီး // နဲ့ စားရင် ကိန်းပြည့် 14 ရပါတယ်။ ကိုယ်ကြိုက်တာ ရွေးပြီး ရလဒ်ကို နှိုင်းယှဉ်ကြည့်ပါ။
အဖြေ ကြည့်ရန်
learner = "Aye"
total_lessons = 70
per_week = 5
weeks = total_lessons // per_week
print(f"Hi {learner}, let's learn Python!")
print(f"Pace: {per_week} lessons per week")
print(f"You will finish all {total_lessons} lessons in {weeks} weeks.")Quick Quiz 1 / 3
Quick Quiz 2 / 3
Quick Quiz 3 / 3
မှတ်ထားရမယ့် အချက်များ
- Python ကို web backend, data analysis, automation နဲ့ AI လုပ်ငန်းတွေမှာ ကျယ်ကျယ်ပြန့်ပြန့် သုံးကြပါတယ်။
- Course က lesson ၇၀ ကို Basic (19), Intermediate (22), Advanced (22), Projects (5), Exercises (2) ဆိုပြီး ခွဲထားလို့ အစဉ်လိုက် သွားပါ။
- Language, standard library နဲ့ pip package တွေက အလွှာ သုံးခု ကွဲပါတယ်။
- Interpreter က file ကို အပေါ်ကနေ အောက် run ပြီး error တက်တဲ့နေရာမှာ ရပ်ပါတယ်။
- Example တိုင်းမှာ output ကို ကြိုခန့်မှန်းပြီးမှ run ပါ။
The Python Tutorial — Python Software Foundation