Python for Beginner
0x01:Ultimate Python ( Printing,Data type,Operation,Variable)
Welcome to First Charater of Ultimate Python လို႔ဘဲ ေခၚလိုက္ၾကရေအာင္......
အရင္ဆံုး ဒီသင္ခန္းစာကို မစခင္မွာ ကြၽန္ေတာ္တို႔
- Python Script ေတြ ဘယ္လို Run ၾကရမလဲ.... Ok သြားၾကရေအာင္.. 😁😁
ဒီေတာ့ U want to write a program hun? ...ၾကည့္ၾကရေအာင္..... အရင္ဆံုး program တစ္ခုကို ေရးေတာ့မယ္ဆိုရင္
1.Gets input from the user
2.Processes the input with some magic
3.Displays output....
ဆိုတာ ဂို သိထားရမယ္....
ဟုတ္ၿပီ ဒါဆို ကြၽန္ေတာ္က ေနာကိဆံုး ျဖစ္တဲ့ Display Output ဆိုတဲ့ အခနိးကေန စသြားရေအာင္ 😉
Display Output
စေရးလိုက္ၾကရေအာင္ pytgon is cool ဆိုတဲ့ စာသားကို... ဘယ္လိုေရးရမလဲဆိုေတာ့
print 'python is cool'
ဒီ Code ဟာဆို python is cool ဆိုတဲ့ စာသားကို print ထုတ္ေပးတယ္ ဆိုတာ သိရလိ္မ့္မယ္..... So Right? ဟုတ္ရဲ႕လား... ေမးခြန္းထုတ္စရာဘဲ....
Right! ထုတ္ေပးတယ္ ဆိုတာ ေတြ႔ရလိမ့္မယ္..... ဒီေနရာမွာ ေျပာခ်င္တာက ကြၽန္ေတာိတို႔ ဟာ print ထုတ္ခ်င္တယ္ ဆိုရင္ စာေတြဟာ string ေတြ ျဖစ္တာေၾကာင့္ ‘ (single quotes) ႏွင့္ ” (double quotes) ကို အဖြငိ့အပိတ္မွာ သံုးေပးရလိမ့္မယ္...
ဟုတ္ၿပီ ဒါဆို print 2 ေၾကာင္း ေရးၾကည့္လိုက္ရေအာင္ ဗ်ာ...
print 'Python is cool'
print 'and its easy too'
ဒါဆို print 2 ေၾကာင္းထုတ္ေပးတာ ေတြ႔ရလိမ့္မယ္... ဟုတ္ၿပီ ဒါဆို ဒီ ၂ ေၾကာင္းကို တစ္ေၾကာင္းတည္းဘဲ ေရးလို႔ မရဘူးလားဆိုေတာ့ ေရးလို႔ရပါတယ္ ဘာလိုလဲဆိုေတာ့ \n ဆိုတာေလးနဲ႔ တြဲေရးေပးရလိမ့္မယ္....
print 'Python is cool\nand its easy too'
ဒါဆို print တစ္ေၾကာင္းတည္း နဲ႔ ေရးလိုရတယ္ ဆိုတာ သေဘာေပါက္မယ္ လို႔ထင္ပါတယ္... တခုခု ကို ေနာက္တစ္ေၾကာင္း ဆင္းေရးခ်ငိတယ္ ဆိုရင္ \n ေလးကို အသံုးျပဳေပးလိုက္ရပါတယ္...ဒိမွာ ေျပာခ်င္တာက \n ဆိုတာကို Computer က ဘယ္လို သိတာလဲ? ...ဘာလို႔ \n ေလးကို ေရးဖို႔လိုတာလဲ... ဟုတ္ၿပီ ဒါကို ဆက္႐ွင္းျပမယ္ေနာ္...
Python is interpreter Language ျဖစိလို႔ဘဲ.... ဆိုလိုတာ က ကြၽန္ေတာိတို႔က ကြၽန္ေတာိတို႔ Program ကို ဘာ further process မွာ မလိုဘဲ Run လို႔ရလို႔ဘဲ... Interpreter ဆိုတာကလည္း program ကို ဖတ္ခ်င္တာဘဲ ျဖစ္ျဖစ္ ေျဖခ်ခ်င္တာဘဲျဖစ္ျဖစ္ အကုန္လံုးကို ဒီထဲမွာဘဲ ေရးလို႔ရတယ္ ဆိုတာပါဘဲ...
ေနာက္တခုက Interger, interger ဆိုတာ အေျခခံအားျဖင့္ Number ေတြေပါ့ ဥပမာ... 1,2,3,44,22 ဆိုတာေတြက interger ေတြေပါ့... decimal number ေတြက်ေတာ့ float လို႔ေခၚျပန္ေရာ..ဥပမာ....22.45,33.55 လိုမ်ိဳးေပါ့ ဒႆမ ဂဏန္းေတြေပါ့..... interger နဲ႔ float ေတြကိုက်ေတာ့ single query, double query ေတြ မပါဘဲrun လို႔ရတာဘဲ....
print 1234
ဟုတ္ၿပီ ဒါဆို data type ေတြ ျဖစ္တဲ့ string,interger,float ေတြကို သိရၿပီေပါ့... ဆက္ေလ့လာရေအာင္...
ဒီတခါေတာ့ number နစ္ခုကို ေပါင္းမယ္ interger 2 ခုကို ေပါင္းမယ္ေပါ့....(13,34)
print 13+34
ဒိလိုဘဲ ေပါင္းေပးလိုက္ရံုဘဲ လြယ္လြယ္ေလးေပါ့
Operation 4 ခု ႐ွိတယ္ ဒါေတြက
- = add (ေပါင္းျခင္း)
- = subtration (ႏႈတ္ျခင္း)
- = multiplation (ေျမာက္ျခင္း)
/ = division (စားျခင္း)
ဟုတ္ၿပီေနာ္ ကဲ့ ဒါဆို i am best ကို ငါးေၾကာင္းေရးၾကည့္မယ္ဆိုရင္ေရာ ဘယ္လိုေရးမလဲ.... very easy!
print 'i am beat\n' *5
i am best ဆိုၿပီး ငါးေၾကာင္းျဖစ္ေနတာ ေတြ႔ရလိမ့္မယ္... ဟုတ္ၿပီ ဘာေၾကာင့္ \n သံုးရလဲဆိုတာ သေဘာေပါက္မွာပါေနာ္ အေပၚမွာ ႐ွင္းျပထားပါတယ္ နားမလည္ရင္ ျပန္ဖတ္ေပးပါ..
1.firat program ေအာက္က စာမ်ိဳးေပၚေအာင္ဘယ္လိုေရးမလဲ..
I am the best person.
You are the worst person.
I am the best person.
You are the worst person.
I am the best person.
You are the worst person.
ဒီလိုမ်ိဳးဆိုရင္ ကြၽန္ေတာ္တို႔က variable ေတြကို အသံုးျပဳရပါေတာ့မယ္ ခင္ဗ်ာ..
ဘယ္လိုလဲဆိုေတာ့..
me = 'I am the best person'
you = 'You are the worst person'
print me
print you
print me
print you
print me
print you
ဒီလိုမ်ိဳးေရးရပါေတာ့တယ္.... me = I am the best person ဆိုၿပီ me ကို variable သတ္မွတ္ေပးရပါေတာ့တယ္ ေနာက္တခုေလ့လာၾကည့္ရေအာင္.
Interger ေတြ သံုးၿပီးေတာ့ေပါ့..
a = 30
b = 50
print a+b
ဆိုေတ့ာ print ထုတ္ေပးမွာသည္ 80 ေပါ့ ဒါ variable ကို ဘယ္လိ ုသံုးရတယ္ ဆုိတာ သေဘာေပါက္မွာပါ..
Basic အေနနဲ႔ ဒီေလာက္ဆို သေဘာေပါက္နားလည္ႏိူင္မယ္လို႔ ထင္ပါတယ္.... ေနာက္ သင္ခန္းစာေတြ ဆက္ေလ့လာၾကရေအာင္
Author #Bl03K_C0D3R
10.12.2017
Congratulations @omicronjohn! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP