├── Function ├── Image ├── Assignment Operator.jpg ├── Comparison Operator.png ├── Data Type.png ├── DataStructureFlow-591x365.png ├── Hanoi Goal.png ├── IMG_0658-e1556096871649.png ├── List │ ├── DataStructureFlow-591x365.psd │ ├── Hanoi │ │ ├── 1_eR2gxp8mKeaEWbbj4-cLMQ.png │ │ ├── Hanoi.gif │ │ ├── Tower_of_Hanoi.jpeg │ │ ├── Tower_of_Hanoi_4.gif │ │ ├── daa-tower-of-hanoi.png │ │ ├── hanoi04d.gif │ │ └── unnamed.gif │ ├── List Definition.PNG │ ├── Non-Primitive.png │ ├── Non.png │ ├── Push.gif │ └── loop-over-python-list-animation.gif ├── Operator.jpg ├── board.png ├── fahrenheit_to_celsius_formulas.png ├── keywords-python.png ├── python-operator-precedence.jpg ├── slide_1.jpg ├── truth-table.png ├── uH6cL.png └── ตัวดำเนินการทางคณิตศาสตร์.jpg ├── Non Primitive ├── Phase1 ├── EP1.py ├── EP10.py ├── EP11.py ├── EP12.py ├── EP13.Assignment1.py ├── EP14.py ├── EP15 Ternary Operator.py ├── EP16.py ├── EP17.py ├── EP18.Assignment2.py ├── EP19.Assignment3.py ├── EP2.py ├── EP20.Assignment4.py ├── EP21.Assignment5.py ├── EP22.Assignment6.py ├── EP23.py ├── EP24.py ├── EP25.py ├── EP26.py ├── EP27.py ├── EP28.py ├── EP29.py ├── EP3.py ├── EP30.py ├── EP31.py ├── EP32.py ├── EP33.py ├── EP34.py ├── EP35.py ├── EP36.py ├── EP4.py ├── EP5.py ├── EP6.py ├── EP7.py ├── EP8.py ├── EP9.py └── String ├── Phase2 ├── DictionaryTutorial.py ├── EP37-Assignment1.py ├── EP38-Assignement2.py ├── EP39.Assignment3.py ├── EP40.Assignment4.py ├── EP41.Assignment5.py ├── EP42.Assignment6.py ├── EP43.Assignment7.py ├── EP44.Assignment8.py ├── EP45.Assignment9.py ├── Functions │ ├── Demo.py │ ├── EP1.py │ ├── EP10.py │ ├── EP11.py │ ├── EP12.py │ ├── EP13.py │ ├── EP14.py │ ├── EP15.py │ ├── EP16.py │ ├── EP17.py │ ├── EP18.py │ ├── EP19.py │ ├── EP2.py │ ├── EP20.py │ ├── EP3.py │ ├── EP4.py │ ├── EP5.Assignment1.py │ ├── EP6.py │ ├── EP7.py │ ├── EP8.py │ ├── EP9.py │ └── python-recursion.png ├── SetOperator.py └── Settutorial.py ├── Phase3 ├── Exception │ ├── Balance.py │ └── EP1.py ├── File │ ├── EP2.py │ ├── Grade.txt │ ├── Score.txt │ └── StudentGrade.py ├── Module │ ├── MainProgram.py │ ├── MainProgram2.py │ ├── MyCalculate │ │ ├── CalculateService.py │ │ └── __pycache__ │ │ │ └── CalculateService.cpython-38.pyc │ └── Mypackage │ │ ├── Weather.py │ │ └── __pycache__ │ │ ├── CalculateService.cpython-38.pyc │ │ └── Weather.cpython-38.pyc ├── Utility Module │ ├── Crackpassword.py │ ├── EP1 Date-Time.py │ ├── EP2 Math-Utill.py │ └── EP3 Random-Utill.py └── __pycache__ │ ├── Calculate.cpython-38.pyc │ ├── CalculateService.cpython-38.pyc │ └── Weather.cpython-38.pyc ├── README.md └── String /Function: -------------------------------------------------------------------------------- 1 | ฟังก์ชั่นคืออะไร / ตัวอย่างฟังก์ชั่น 2 | การสร้างฟังก์ชั่น 3 | การเรียกฟังก์ชั่น 4 | Global Variable / Local Variable 5 | Arguments / Parameter 6 | 2 Arguments 7 | Arbitrary Arguments *args 8 | Keywords Parameter 9 | Default Parameter 10 | Arbitrary Arguments **kwargs -------------------------------------------------------------------------------- /Image/Assignment Operator.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/Assignment Operator.jpg -------------------------------------------------------------------------------- /Image/Comparison Operator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/Comparison Operator.png -------------------------------------------------------------------------------- /Image/Data Type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/Data Type.png -------------------------------------------------------------------------------- /Image/DataStructureFlow-591x365.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/DataStructureFlow-591x365.png -------------------------------------------------------------------------------- /Image/Hanoi Goal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/Hanoi Goal.png -------------------------------------------------------------------------------- /Image/IMG_0658-e1556096871649.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/IMG_0658-e1556096871649.png -------------------------------------------------------------------------------- /Image/List/DataStructureFlow-591x365.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/List/DataStructureFlow-591x365.psd -------------------------------------------------------------------------------- /Image/List/Hanoi/1_eR2gxp8mKeaEWbbj4-cLMQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/List/Hanoi/1_eR2gxp8mKeaEWbbj4-cLMQ.png -------------------------------------------------------------------------------- /Image/List/Hanoi/Hanoi.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/List/Hanoi/Hanoi.gif -------------------------------------------------------------------------------- /Image/List/Hanoi/Tower_of_Hanoi.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/List/Hanoi/Tower_of_Hanoi.jpeg -------------------------------------------------------------------------------- /Image/List/Hanoi/Tower_of_Hanoi_4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/List/Hanoi/Tower_of_Hanoi_4.gif -------------------------------------------------------------------------------- /Image/List/Hanoi/daa-tower-of-hanoi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/List/Hanoi/daa-tower-of-hanoi.png -------------------------------------------------------------------------------- /Image/List/Hanoi/hanoi04d.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/List/Hanoi/hanoi04d.gif -------------------------------------------------------------------------------- /Image/List/Hanoi/unnamed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/List/Hanoi/unnamed.gif -------------------------------------------------------------------------------- /Image/List/List Definition.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/List/List Definition.PNG -------------------------------------------------------------------------------- /Image/List/Non-Primitive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/List/Non-Primitive.png -------------------------------------------------------------------------------- /Image/List/Non.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/List/Non.png -------------------------------------------------------------------------------- /Image/List/Push.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/List/Push.gif -------------------------------------------------------------------------------- /Image/List/loop-over-python-list-animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/List/loop-over-python-list-animation.gif -------------------------------------------------------------------------------- /Image/Operator.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/Operator.jpg -------------------------------------------------------------------------------- /Image/board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/board.png -------------------------------------------------------------------------------- /Image/fahrenheit_to_celsius_formulas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/fahrenheit_to_celsius_formulas.png -------------------------------------------------------------------------------- /Image/keywords-python.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/keywords-python.png -------------------------------------------------------------------------------- /Image/python-operator-precedence.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/python-operator-precedence.jpg -------------------------------------------------------------------------------- /Image/slide_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/slide_1.jpg -------------------------------------------------------------------------------- /Image/truth-table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/truth-table.png -------------------------------------------------------------------------------- /Image/uH6cL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/uH6cL.png -------------------------------------------------------------------------------- /Image/ตัวดำเนินการทางคณิตศาสตร์.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Image/ตัวดำเนินการทางคณิตศาสตร์.jpg -------------------------------------------------------------------------------- /Non Primitive: -------------------------------------------------------------------------------- 1 | การนิยาม , constructor 2 | การเข้าถึงข้อมูล 3 | การแก้ไขข้อมูล 4 | แสดงผลด้วย Loop 5 | ตรวจสอบข้อมูล 6 | นับจำนวนสมาชิก (len) 7 | len() ทำงานร่วมกับ Loop For 8 | การสร้างและเพิ่มข้อมูล 9 | ทำงานร่วมกับ List 10 | การลบข้อมูล del , การลบแบบ list 11 | ค้นหาและนับจำนวนสมาชิก (Count) 12 | ค้นหาสมาชิกด้วย Index 13 | การ Sort ข้อมูล -------------------------------------------------------------------------------- /Phase1/EP1.py: -------------------------------------------------------------------------------- 1 | print("Hellos") -------------------------------------------------------------------------------- /Phase1/EP10.py: -------------------------------------------------------------------------------- 1 | #ตัวดำเนินการทางตรรกศาสตร์ 2 | 3 | #AND = และ 4 | #OR = หรือ 5 | #NOT = ไม่ 6 | 7 | #คำตอบที่ได้ => จริง / เท็จ 8 | 9 | x = (10>5) #ค่า x = bool 10 | y = (10==5) #ค่า y = bool 11 | 12 | # z = (5>10) and (10==5) 13 | # 5>10 and 10 == 5 14 | z = (10>5) or (10==5) 15 | 16 | print(not z) 17 | -------------------------------------------------------------------------------- /Phase1/EP11.py: -------------------------------------------------------------------------------- 1 | #Compound Assignment 2 | 3 | x=10 4 | print("ก่อน",x) 5 | # x+=5 # x=x+5 6 | # x-=15 # x = x-15 7 | # x*=5 # x=x*5 8 | # x/=5 # x=x/5 9 | # x//=5 10 | # x**=2 # x= x**2 11 | x%=3 12 | print("หลัง",x) -------------------------------------------------------------------------------- /Phase1/EP12.py: -------------------------------------------------------------------------------- 1 | #ลำดับความสำคัญของตัวดำเนินการทางคณิตศาสตร์ 2 | 3 | x=5+2/10*2-5 # 5+0.4-5 4 | print(x) -------------------------------------------------------------------------------- /Phase1/EP13.Assignment1.py: -------------------------------------------------------------------------------- 1 | #โปรแกรมคำนวณค่า BMI (ดัชนีมวลกาย) 2 | # BMI = น้ำหนัก (kg) / ส่วนสูง * ส่วนสูง (m) 3 | # input / convert to integer 4 | weight=int(input("ป้อนน้ำหนักของคุณ (kg):")) 5 | high=int(input("ป้อนส่วนสูงของคุณ (cm) :"))/100 6 | print("BMI = ",weight/(high**2)) -------------------------------------------------------------------------------- /Phase1/EP14.py: -------------------------------------------------------------------------------- 1 | age=int(input("ป้อนอายุของคุณ :")) 2 | #35 3 | if age>=15 and age <=20: 4 | print("วัยรุ่น") 5 | elif age>=20 and age<=29: 6 | print("วัยหนุ่มสาว") 7 | elif age>=30 and age<=39: 8 | print("วัยผู้ใหญ่") 9 | elif age>=80: 10 | print("วัยชรา") 11 | else : 12 | print("วัยเด็ก") 13 | 14 | print("จบโปรแกรม") 15 | 16 | # 15 - 20 => วัยรุ่น 17 | # 21 - 29 => วัยหนุ่มสาว 18 | # 30 - 39 => วัยผู้ใหญ่ 19 | 20 | 21 | # and or not -------------------------------------------------------------------------------- /Phase1/EP15 Ternary Operator.py: -------------------------------------------------------------------------------- 1 | age=int(input("ป้อนอายุของคุณ :")) 2 | #Ternary Operator 3 | print("วัยรุ่น") if age>=15 else print("วัยเด็ก") 4 | 5 | print("จบโปรแกรม") 6 | 7 | # 15 - 20 => วัยรุ่น 8 | 9 | 10 | # and or not -------------------------------------------------------------------------------- /Phase1/EP16.py: -------------------------------------------------------------------------------- 1 | # if ซ้อน if 2 | age=int(input("ป้อนอายุของคุณ : ")) 3 | 4 | if age<=15: 5 | if age==15: 6 | print("ม.3") 7 | elif age==14: 8 | print("ม.2") 9 | elif age==13: 10 | print("ม.1") 11 | else : 12 | print("ประถมศึกษา") 13 | else : 14 | print("ม.ปลาย") 15 | 16 | print("จบโปรแกรม") -------------------------------------------------------------------------------- /Phase1/EP17.py: -------------------------------------------------------------------------------- 1 | # pass 2 | age=int(input("ป้อนอายุของคุณ : ")) 3 | 4 | if age<=15: 5 | if age==15: 6 | pass 7 | elif age==14: 8 | pass 9 | else : 10 | print("ประถมศึกษา") 11 | else : 12 | print("ม.ปลาย") 13 | 14 | print("จบโปรแกรม") -------------------------------------------------------------------------------- /Phase1/EP18.Assignment2.py: -------------------------------------------------------------------------------- 1 | # เขียนโปรแกรมหาตัวเลข มาก / น้อย 2 | 3 | a=int(input("ป้อนตัวเลขที่ 1 :")) 4 | b=int(input("ป้อนตัวเลขที่ 2 :")) 5 | 6 | if a>b : 7 | print(a," มากกว่า ",b) 8 | else : 9 | print(a," น้อยกว่า ",b) 10 | -------------------------------------------------------------------------------- /Phase1/EP19.Assignment3.py: -------------------------------------------------------------------------------- 1 | #หาเลขคู่ / คี่ 2 | 3 | number = int(input("ป้อนตัวเลขของคุณ :")) 4 | 5 | # ถ้าหาร 2 ลงตัว => คู่ 6 | if number % 2 == 0: 7 | print("เป็นเลขคู่") 8 | else : 9 | print("เป็นเลขคี่") 10 | -------------------------------------------------------------------------------- /Phase1/EP2.py: -------------------------------------------------------------------------------- 1 | """ 2 | คำสั่งนี้ใช้ในการแสดงผลข้อความ 3 | และรองแสดงได้ทุกชนิด 4 | นะครับทุกคน 5 | """ 6 | print("Hello World 555") -------------------------------------------------------------------------------- /Phase1/EP20.Assignment4.py: -------------------------------------------------------------------------------- 1 | #แลกเงินและหาจำนวนแบงค์ 2 | 3 | # 2000 => 1000 => 2 ใบ 4 | # 1500 => 1 ใบ , 500 = 1 ใบ 5 | # 1800 => 1 ใบ , 500 = 1 ใบ , 100 => 3 ใบ 6 | # 100 => 50 => 2 ใบ 7 | 8 | number = int(input("ป้อนจำนวนเงินของคุณ : ")) 9 | 10 | # 1500 11 | if number>=1000: 12 | print("1000 บาท = ",number//1000,"ใบ") # 1 ใบ 13 | number%=1000 # 1500 % 1000 = 500 14 | 15 | if number>=500: 16 | print("500 บาท = ",number//500,"ใบ") 17 | number%=500 18 | 19 | if number>=100: 20 | print("100 บาท = ",number//100,"ใบ") 21 | number%=100 22 | 23 | if number>=50: 24 | print("50 บาท = ",number//50,"ใบ") 25 | number%=50 26 | 27 | if number>=20: 28 | print("20 บาท = ",number//20,"ใบ") 29 | number%=20 -------------------------------------------------------------------------------- /Phase1/EP21.Assignment5.py: -------------------------------------------------------------------------------- 1 | # แปลง ค.ศ เป็น พ.ศ 2 | # แปลง พ.ศ เป็น ค.ศ 3 | 4 | number = int(input("ป้อน พ.ศ :")) 5 | 6 | # แปลง ค.ศ เป็น พ.ศ + 543 7 | # แปลง พ.ศ เป็น ค.ศ - 543 8 | number=number-543 9 | 10 | print("เป็น ค.ศ = ",number) -------------------------------------------------------------------------------- /Phase1/EP22.Assignment6.py: -------------------------------------------------------------------------------- 1 | weight=int(input("ป้อนน้ำหนักของคุณ (kg):")) 2 | high=int(input("ป้อนส่วนสูงของคุณ (cm) :"))/100 3 | bmi = weight/(high**2) 4 | 5 | if bmi>=0 and bmi<18.0: 6 | result="ผอม" 7 | elif bmi>=18.5 and bmi<=22.9: 8 | result="สมส่วน" 9 | elif bmi>=23.0 and bmi<=24.9: 10 | result="น้ำหนักเกิน" 11 | elif bmi>=25.0 and bmi<=29.9: 12 | result="โรคอ้วน ระดับที่ 1" 13 | elif bmi>30: 14 | result="โรคอ้วนระดับอันตราย" 15 | else : 16 | result="ไม่ทราบค่าที่ชัดเจน" 17 | 18 | print("ค่า bmi = ", bmi ,"ทำนายว่า =",result) -------------------------------------------------------------------------------- /Phase1/EP23.py: -------------------------------------------------------------------------------- 1 | name="11504566" 2 | 3 | if name.endswith("0"): 4 | print("ถูกหวย") 5 | else : 6 | print("ไม่ถูกหวย") -------------------------------------------------------------------------------- /Phase1/EP24.py: -------------------------------------------------------------------------------- 1 | #แปลงอุณหภูมิ 2 | temp = input("ป้อนอุณหภูมิ (องศา) :") #45C 3 | 4 | degree= int(temp[:-1]) #45 5 | unit=temp[-1].upper() #C 6 | 7 | 8 | if unit=="C": 9 | result=(9*degree)/5+32 10 | unit_result="ฟาเรนไฮน์" 11 | if unit=="F": 12 | result=(degree-32)*5/9 13 | unit_result="เซลเซียส" 14 | 15 | print("แปลงตัวเลข = ",temp," เป็น ",unit_result," = ",result) -------------------------------------------------------------------------------- /Phase1/EP25.py: -------------------------------------------------------------------------------- 1 | # โครงสร้างควบคุมแบบทำซ้ำ 2 | summation=0 3 | 4 | for i in range(1,11): # summation 5 | print("รอบที่ = ",i) 6 | 7 | print("ผลรวม = ", summation) 8 | print("เฉลี่ย = ", summation/10) -------------------------------------------------------------------------------- /Phase1/EP26.py: -------------------------------------------------------------------------------- 1 | # Loop ซ้อน Loop 2 | i=1 3 | while i<=3 : 4 | j=1 # ตัวนับ 5 | while j<=5: 6 | print("รอบที่ = ",i," ตำแหน่งที่ = ", j) 7 | j+=1 8 | i+=1 9 | 10 | 11 | for i in range(1,4): 12 | print("รอบที่ = ",i) 13 | for j in range(1,6): 14 | print("ตำแหน่งที่ = ", j) -------------------------------------------------------------------------------- /Phase1/EP27.py: -------------------------------------------------------------------------------- 1 | # แม่สูตรคูณ 2 | 3 | start=int(input("ป้อนแม่สูตรคูณเริ่มต้น = ")) # 1 4 | stop=int(input("ป้อนแม่สูตรคูณสุดท้าย = ")) # 4 5 | 6 | for x in range(start,stop+1): 7 | print("แม่ = ",x) 8 | for y in range(1,13): 9 | print(x,'x',y ," = ",(x*y)) 10 | -------------------------------------------------------------------------------- /Phase1/EP28.py: -------------------------------------------------------------------------------- 1 | # break / continue 2 | 3 | for i in range(1,11): 4 | print(i) 5 | if(i==5): 6 | break 7 | 8 | print("จบโปรแกรม") -------------------------------------------------------------------------------- /Phase1/EP29.py: -------------------------------------------------------------------------------- 1 | start , stop = 1,3 2 | sum ,avg =0,0 3 | while (start<=stop): 4 | number=int(input("ป้อนตัวเลขของคุณ :")) 5 | sum+=number # บวกเลขที่ป้อนแต่ละรอบ 6 | start+=1 7 | 8 | avg=sum/stop 9 | print("ผลรวม = ", sum) 10 | print("ค่าเฉลี่ย = ", avg) -------------------------------------------------------------------------------- /Phase1/EP3.py: -------------------------------------------------------------------------------- 1 | #string => ข้อความ ตัวอักษร ' "" ''' 2 | #number => integer , float 3 | #boolean => true , false 4 | print(-1) 5 | print(0) 6 | print("1"+"9") 7 | print(3.99) 8 | print(True) 9 | print(False) 10 | print("kongruksiam \n" + "studio") -------------------------------------------------------------------------------- /Phase1/EP30.py: -------------------------------------------------------------------------------- 1 | sum = 0 2 | while True: 3 | number=int(input("ป้อนตัวเลขของคุณ :")) 4 | sum+=number # บวกเลขที่ป้อนแต่ละรอบ 5 | if sum>=100: 6 | break 7 | print("ผลรวม = ", sum) 8 | -------------------------------------------------------------------------------- /Phase1/EP31.py: -------------------------------------------------------------------------------- 1 | # ค้นหาตัวเลข มากสุด / น้อยสุด 2 | 3 | max ,min = 0,9999 4 | 5 | while True : 6 | number=int(input("ป้อนตัวเลขของคุณ :")) 7 | #กระโดดออกจาก loop 8 | if number<0 : 9 | break 10 | if number>max : 11 | max=number 12 | if number 0,1,2,3,4 23 | 24 | """ 25 | 26 | """ 27 | for row in range(number) : 28 | for column in range(number): 29 | print("x",end="") 30 | print(" ") 31 | -------------------------------------------------------------------------------- /Phase1/EP34.py: -------------------------------------------------------------------------------- 1 | # ตารางหมากฮอต 2 | 3 | """ 4 | xxx 5 | xxx 6 | xxx 7 | 8 | x = สีน้ำตาล 9 | o = สีขาว 10 | """ 11 | number=int(input("ป้อนขนาด = ")) 12 | for row in range(number) : 13 | for column in range(number): 14 | print("x",end="") if (row+column)%2 == 0 else print("o",end="") 15 | 16 | print(" ") 17 | 18 | # 3 x 3 19 | # row = 0 + column = 0 20 | # row = 0 + 1 21 | # row = 0 + 2 22 | 23 | # row = 1 + column = 0 24 | # row = 1 + 1 25 | # row = 1 + 2 26 | 27 | # row = 2 + column = 0 28 | # row = 2 + 1 29 | # row = 2 + 2 30 | 31 | 32 | """ 33 | xox 34 | oxo 35 | xox 36 | """ -------------------------------------------------------------------------------- /Phase1/EP35.py: -------------------------------------------------------------------------------- 1 | # สร้างขอบตาราง 2 | 3 | number=int(input("ป้อนขนาด = ")) 4 | for row in range(number) : 5 | for column in range(number): 6 | if row==0 or row==number-1 or column==0 or column==number-1: 7 | print("x",end="") 8 | else: 9 | print(" ",end="") 10 | print(" ") 11 | -------------------------------------------------------------------------------- /Phase1/EP36.py: -------------------------------------------------------------------------------- 1 | # เกมทายเลขลูกเต๋า 2 | # 1,2,3,4,5,6 3 | 4 | import random 5 | #สุ่มเลขลูกเต๋า 6 | myrandom = random.randrange(1,7) # 1 - 6 7 | k=1 8 | correct=False 9 | print("คุณมีโอกาสตอบ 3 ครั้ง \n") 10 | print(myrandom) 11 | while True: 12 | number=int(input("ป้อนคำตอบของคุณ = ")) 13 | correct=(number==myrandom) # true / false 14 | if not correct : 15 | if(number>myrandom): 16 | print("น้อยกว่า") 17 | if(number 20 7 | # 10 => "10" 8 | 9 | # บวกเลข 10 | z=float(z) 11 | # 10+3.14 = 13.14 12 | # "10" + "20" ="1020" => result 13 | 14 | z=z+50 15 | # string => int 16 | # int => string 17 | 18 | #string => float 19 | #float => string 20 | 21 | # int => float 22 | # float => int 23 | print(z) -------------------------------------------------------------------------------- /Phase1/EP7.py: -------------------------------------------------------------------------------- 1 | # input 2 | x=int(input("ป้อนตัวเลขตัวที่ 1 : ")) #รับค่าที่ผู้ใช้ป้อนแล้วเก็บลงตัวแปร fname 3 | y=int(input("ป้อนตัวเลขตัวที่ 2 : ")) 4 | #process & output 5 | print(x+y) -------------------------------------------------------------------------------- /Phase1/EP8.py: -------------------------------------------------------------------------------- 1 | # ตัวดำเนินการทางคณิตศาสตร์ 2 | x = 10 3 | y = 3 4 | 5 | print("ผลบวก" , x+y) 6 | print("ผลลบ" , x-y) 7 | print("ผลคูณ", x*y) 8 | print("ผลหาร",x/y) 9 | print("หารปัดเศษ", x//y) 10 | print("ยกกำลัง",x**y) 11 | print("หารเอาเศษ",x%y) -------------------------------------------------------------------------------- /Phase1/EP9.py: -------------------------------------------------------------------------------- 1 | #ตัวดำเนินการเปรียบเทียบ​ 2 | 3 | # นำข้อมูลอย่างน้อย 2 ค่ามาเปรียบเทียบกัน 4 | # ชนิดข้อมูลเหมือนกัน 5 | # คำตอบ 2 คำตอบ => จริง / เท็จ 6 | 7 | x,y,z = 8, 7,5 8 | 9 | # print("ค่า x มากกว่า y หรือไม่ ? : ",x>y) 10 | # print("ค่า x น้อยกว่า y หรือไม่ ? :", x=y) 15 | # print("ค่า x น้อยกว่า หรือ เท่ากับ ค่า y หรือไม่ ?", x<=y) 16 | 17 | #และ 18 | print("ค่า x มากกว่า y และ y มากกว่า z หรือไม่ ? : ",x>y>z) 19 | print("ค่า x น้อยกว่า y และ y น้อยกว่า z หรือไม่ ? : ",x true , false 7 | การต่อ String (Concatinate) + 8 | การจัดรูปแบบการแสดงผล format + {} 9 | นับจำนวนคำในประโยค (count) 10 | เช็คคำขึ้นต้น / เช็คคำลงท้าย -------------------------------------------------------------------------------- /Phase2/DictionaryTutorial.py: -------------------------------------------------------------------------------- 1 | # list , tuple 2 | lis=["สีแดง","สีเหลือง","สีเขียว"] 3 | tup=("สีแดง","สีเหลือง","สีเขียว") 4 | 5 | #dictionary => key (การเข้าถึงข้อมูล), value (ค่าของข้อมูล) 6 | 7 | market={ 8 | "ร้านป้าพร":{ 9 | "name":"ป้าพร", 10 | "menu":["กะเพราไก่","ก๋วยเตี๋ยว"], 11 | "zone":'ตะวันออก' 12 | }, 13 | "ร้านลุงป้อม":{ 14 | "name":"น้าจ๊อบ", 15 | "menu":["มะม่วง","ทุเรียน"], 16 | "zone":'ทางเข้าตลาด' 17 | }, 18 | "ร้านน้าใจ":{ 19 | "name":"น้าใจ", 20 | "menu":["นมปั่น","ชาเย็น"], 21 | "zone":'ข้าง 7-11' 22 | } 23 | } 24 | 25 | if "ทุเรียน" in market["ร้านป้าพร"]["menu"]: 26 | print("เป็น") 27 | else : 28 | print("ไม่เป็น") 29 | -------------------------------------------------------------------------------- /Phase2/EP37-Assignment1.py: -------------------------------------------------------------------------------- 1 | # Assignment รับและเรียงลำดับข้อมูลตัวเลข 2 | number=[] 3 | while True: 4 | x=int(input("ป้อนตัวเลขของคุณ :")) 5 | if x<0: 6 | break 7 | number.append(x) 8 | 9 | print("ก่อนเรียง=>",number) 10 | number.sort() 11 | print("น้อยไปมาก=>",number) 12 | number.reverse() 13 | print("มากไปน้อย=>",number) 14 | print("จบโปรแกรม") -------------------------------------------------------------------------------- /Phase2/EP38-Assignement2.py: -------------------------------------------------------------------------------- 1 | # Assignment หาค่ามากสุด / ต่ำสุด / ผลรวม ตัวเลข 2 | number=[] 3 | while True: 4 | x=int(input("ป้อนตัวเลขของคุณ :")) 5 | if x<0: 6 | break 7 | number.append(x) 8 | 9 | print(number) 10 | print("ค่าที่น้อยที่สุด คือ ",min(number)) 11 | print("ค่าที่มากที่สุด คือ ",max(number)) 12 | print("ผลรวม คือ ",sum(number)) -------------------------------------------------------------------------------- /Phase2/EP39.Assignment3.py: -------------------------------------------------------------------------------- 1 | # Assignment หากลุ่มเลขคู่ / เลขคี่ 2 | number=[] 3 | odd=[] #เลขคี่ 4 | even=[] #เลขคู่ 5 | while True: 6 | x=int(input("ป้อนตัวเลขของคุณ :")) 7 | if x<0: 8 | break 9 | if x%2 == 0: 10 | even.append(x) 11 | else : 12 | odd.append(x) 13 | number.append(x) 14 | 15 | print("ตัวเลขทั้งหมด =>" ,number) 16 | print("เลขคู่ => ",even) 17 | print("เลขคี่ => ",odd) -------------------------------------------------------------------------------- /Phase2/EP40.Assignment4.py: -------------------------------------------------------------------------------- 1 | #เรียงลำดับชื่อ 2 | student=["สมพร","แก้ว","จอมขวัญ","อัมพร","ก้อง","กล้า"] 3 | 4 | print(student) 5 | student.sort() 6 | print(student) 7 | student.reverse() 8 | print(student) -------------------------------------------------------------------------------- /Phase2/EP41.Assignment5.py: -------------------------------------------------------------------------------- 1 | # เรียงสมาชิกหลังสุด => หน้าสุด 2 | 3 | fruit=["มะม่วง","มะยม","มะนาว","ทุเรียน"] 4 | print(fruit) 5 | fruit=fruit[::-1] 6 | print(fruit) -------------------------------------------------------------------------------- /Phase2/EP42.Assignment6.py: -------------------------------------------------------------------------------- 1 | # หาค่าเลขยกกำลัง 2 | number=[1,2,3,4,5,6,7] 3 | 4 | print(number) 5 | #ปกติ 6 | # for i in range(len(number)): 7 | # number[i]=number[i]**2 8 | # print(number) 9 | 10 | #ลดรูป 11 | number=[i*i for i in number] 12 | print(number) -------------------------------------------------------------------------------- /Phase2/EP43.Assignment7.py: -------------------------------------------------------------------------------- 1 | # จับคู่คำทักทาย / บุคคล 2 | 3 | """ 4 | Hi , Hello 5 | ก้อง , แก้ม 6 | 7 | Hi ก้อง , Hi แก้ม , Hello ก้อง , Hello แก้ม 8 | 9 | """ 10 | 11 | greeting=["สวัสดี","Hi", "Hello","Good Bye"] 12 | people=["ก้อง","แก้ม","โจ้"] 13 | result=[] 14 | #ลดรูป 15 | result=[x+y for x in greeting for y in people] 16 | print(result) -------------------------------------------------------------------------------- /Phase2/EP44.Assignment8.py: -------------------------------------------------------------------------------- 1 | #การจับคู่สินค้าและราคา 2 | 3 | fruit=["มะม่วงดอง","แตงโมปั่น","ฝรั่งแซ่บ๊วย"] 4 | price=[50,30,15] 5 | 6 | for x,y in zip(fruit,price[::-1]): 7 | print("สินค้า = ",x , "ราคา = ",y) -------------------------------------------------------------------------------- /Phase2/EP45.Assignment9.py: -------------------------------------------------------------------------------- 1 | #การค้นหาและนับจำนวนตัวอักษรในสมาชิก 2 | 3 | message=["aa","aab","cba","bba","aba","cca","aaa","aabaac"] 4 | result=[] 5 | 6 | for item in message: 7 | result.append(item.count("a")) 8 | print(result) -------------------------------------------------------------------------------- /Phase2/Functions/Demo.py: -------------------------------------------------------------------------------- 1 | def hanoi (n,a,b,c): 2 | if n==0 : 3 | return 4 | hanoi(n-1,a,c,b) 5 | print("ย้าย = ",n ," จาก = ",a ," ไป = ",c) 6 | hanoi(n-1,b,a,c) 7 | 8 | hanoi(3,"A","B","C") -------------------------------------------------------------------------------- /Phase2/Functions/EP1.py: -------------------------------------------------------------------------------- 1 | # สาเหตุที่เราต้องเขียน function 2 | 3 | a,b,c,d=10,23,40,50 4 | 5 | if a%2 == 0: 6 | print("เลขคู่") 7 | else : 8 | print("เลขคี่") 9 | 10 | if b%2 == 0: 11 | print("เลขคู่") 12 | else : 13 | print("เลขคี่") 14 | 15 | if c%2 == 0: 16 | print("เลขคู่") 17 | else : 18 | print("เลขคี่") 19 | 20 | if d%2 == 0: 21 | print("เลขคู่") 22 | else : 23 | print("เลขคี่") -------------------------------------------------------------------------------- /Phase2/Functions/EP10.py: -------------------------------------------------------------------------------- 1 | # **kwargs 2 | 3 | # *args => ค่าใน parameter มีได้หลายค่า 4 | def add(*number): 5 | sum=0 6 | for i in range(len(number)): 7 | sum+=number[i] 8 | print(sum) 9 | 10 | #ชื่อ Parameter มีหลายชื่อ 11 | def displayData(**item): 12 | print(item) 13 | 14 | 15 | displayData(fname="Kong",lname="Ruksiam") 16 | displayData(fname="Kong",lname="Ruksiam",city="กรุงเทพ") 17 | displayData(fname="Kong",lname="Ruksiam",status="โสด") 18 | displayData(fname="Kong",lname="Ruksiam",age=20,city="กรุงเทพ",status="แต่งงาน") 19 | displayData(fname="Kong",lname="Ruksiam",age=20,city="กรุงเทพ",status="แต่งงาน",job="Programmer") 20 | displayData(fname="Kong") 21 | displayData(fname="Kong",lname="Ruksiam",country="ระยอง") -------------------------------------------------------------------------------- /Phase2/Functions/EP11.py: -------------------------------------------------------------------------------- 1 | # ฟังก์ชั่น เรียก ฟังก์ชั่น 2 | def displayFood(): 3 | print("หูฉลาม") 4 | 5 | def displayCity(): 6 | print("สวัสดีกรุงเทพ") 7 | displayFood() 8 | 9 | 10 | displayCity() -------------------------------------------------------------------------------- /Phase2/Functions/EP12.py: -------------------------------------------------------------------------------- 1 | # Recursive Function 2 | 3 | 4 | """ 5 | หาจุดวนซ้ำ 6 | หาจุดออกจาก function (return) 7 | ต้องมี parameter 8 | 9 | 1-5 โดยไม่ใช้ คำสั่ง loop 10 | """ 11 | 12 | def addNumber(number): 13 | if number==5: 14 | return 15 | print(number+1) # 0 16 | number+=1 #1 17 | addNumber(number) 18 | 19 | def summation(number): 20 | if number==1: 21 | return number 22 | else : 23 | return number+summation(number-1) 24 | 25 | 26 | x=summation(4) # ? = 5+4+3+2+1 27 | print(x) 28 | 29 | """ 30 | 5 31 | 5 + summation(4) 32 | 5 + 4 + summation(3) 33 | 5 + 4 + 3 + summation(2) 34 | 5 + 4 + 3 + 2 + summation(2-1) 35 | 5 + 4 + 3 + 2 + 1 36 | """ -------------------------------------------------------------------------------- /Phase2/Functions/EP13.py: -------------------------------------------------------------------------------- 1 | # Factorial 2 | def factorial(number): 3 | if number==1: 4 | return number 5 | else : 6 | return number * factorial(number-1) 7 | 8 | 9 | 10 | 11 | x=factorial(8) 12 | print(x) 13 | 14 | """ 15 | 3! 16 | 17 | 3 18 | 3 x factorial(2) 19 | 3 x 2 x 1 = 6 20 | 21 | 22 | """ 23 | 24 | -------------------------------------------------------------------------------- /Phase2/Functions/EP14.py: -------------------------------------------------------------------------------- 1 | # Fibonacci number 2 | 3 | # 0, 1, 4 | 5 | # f0 = ? , f1 = ? 6 | 7 | def fibonacci(number): 8 | if number<=1: 9 | return number 10 | else : 11 | #เลขลำดับถัดไป 12 | return fibonacci(number-1) + fibonacci(number-2) 13 | 14 | for i in range(10): # 0 - 4 15 | print(fibonacci(i)) # 0, 1, 1, 2 , 3 16 | 17 | 18 | """ 19 | i = 0 20 | i = 1 21 | i = 2 22 | i = 3 23 | i = 4 24 | 25 | 26 | 0 , 1 , 1 , 2 , 3 27 | """ -------------------------------------------------------------------------------- /Phase2/Functions/EP15.py: -------------------------------------------------------------------------------- 1 | # Pass 2 | 3 | def getName(name): 4 | if name =="kong": 5 | print("ยินดีด้วย") 6 | else : 7 | pass 8 | 9 | -------------------------------------------------------------------------------- /Phase2/Functions/EP16.py: -------------------------------------------------------------------------------- 1 | # lambda function 2 | 3 | 4 | def myPower(x): 5 | # x= ตัวเลข 6 | # a = เลขชื้กำลัง 7 | return lambda a : 5**a 8 | 9 | 10 | y=myPower(5) 11 | result=y(3) 12 | 13 | print(result) -------------------------------------------------------------------------------- /Phase2/Functions/EP17.py: -------------------------------------------------------------------------------- 1 | # assignment 2 | 3 | def summation(number): 4 | total,avg=0,0 5 | for i in number : 6 | total+=i 7 | avg=total/len(number) 8 | return total,avg 9 | 10 | 11 | 12 | x=[1,2,3] 13 | y,z=summation(x) 14 | print(y) 15 | print(z) -------------------------------------------------------------------------------- /Phase2/Functions/EP18.py: -------------------------------------------------------------------------------- 1 | # หาจำนวนตัวอักษรพิมพ์เล็ก/พิมพ์ใหญ่ 2 | 3 | def checkString(message): 4 | result={"UPPER":0,"LOWER":0} 5 | for c in message: 6 | if c.isupper(): 7 | result["UPPER"]+=1 8 | elif c.islower(): 9 | result["LOWER"]+=1 10 | else: 11 | pass 12 | return result 13 | 14 | message=input("input your message :") 15 | x=checkString(message) 16 | print(x) -------------------------------------------------------------------------------- /Phase2/Functions/EP19.py: -------------------------------------------------------------------------------- 1 | data={"191":"แจ้งเหตุด่วน","1668":"รถโรงพยาบาล","1447":"ดับเพลิง"} 2 | 3 | def searchNumber(message): 4 | for key , value in data.items(): 5 | if value==message: 6 | print("เบอร์ติดต่อ = ",key) 7 | else : 8 | print("ไม่มีข้อมูล") 9 | return 10 | 11 | message=input("ป้อนข้อมูลที่ต้องการ = ") 12 | searchNumber(message) -------------------------------------------------------------------------------- /Phase2/Functions/EP2.py: -------------------------------------------------------------------------------- 1 | # การสร้าง function / เรียก function 2 | 3 | # def ชื่อฟังก์ชั่น () : 4 | # statement 5 | 6 | def sayHi(): 7 | print("Hello Function") 8 | 9 | def sayThailand(): 10 | print("สวัสดี") 11 | -------------------------------------------------------------------------------- /Phase2/Functions/EP20.py: -------------------------------------------------------------------------------- 1 | #tower of hanoi 2 | 3 | def hanoi(n,a,b,c): 4 | if(n==0): 5 | return 6 | hanoi(n-1,a,c,b) 7 | print("จานที่ = ",n ,"จาก = ",a," ไป = ",c) 8 | hanoi(n-1,b,a,c) 9 | 10 | hanoi(4,"A","B","C") -------------------------------------------------------------------------------- /Phase2/Functions/EP3.py: -------------------------------------------------------------------------------- 1 | # Global Variable / Local Variable 2 | 3 | def displayNumber(): 4 | x=50 5 | a=100 6 | print("Hello = ",a," ใน") 7 | 8 | 9 | #โปรแกรมหลัก 10 | a=200 11 | displayNumber() 12 | print("นอก = ",a) 13 | 14 | # นาย x ดารา => x ทั่วประเทศรู้จัก (Global) 15 | # นาย x หมู่บ้านแสนสุข => x ในหมู่บ้าน (Local) -------------------------------------------------------------------------------- /Phase2/Functions/EP4.py: -------------------------------------------------------------------------------- 1 | # Arguments / Parameter 2 | 3 | def myData(a,b,c): 4 | print("ชื่อ = ",a," นามสกุล = ",b,"อายุ = ",c) 5 | 6 | def addition(a,b): 7 | print("ผลรวม = ",a+b) 8 | 9 | x=5 10 | y=9 11 | addition(x,y) 12 | 13 | # Arguments => ค่าที่ส่งเข้าไปใน function => fname , lname , age (ตอนที่เรียกใช้ฟังก์ชั่น) 14 | # Parameter => ค่าตัวแปรที่รับข้อมูลที่ส่งมาทำงาน (Arguments) => a , b , c 15 | 16 | # อาส่ง - พารับ 17 | -------------------------------------------------------------------------------- /Phase2/Functions/EP5.Assignment1.py: -------------------------------------------------------------------------------- 1 | # Assignment คู่ / คี่ 2 | def searchNumber(number): 3 | if number % 2 == 0: 4 | print("เลขคู่") 5 | else : 6 | print("เลขคี่") 7 | 8 | a,b,c,d=10,23,40,50 9 | 10 | searchNumber(b) 11 | -------------------------------------------------------------------------------- /Phase2/Functions/EP6.py: -------------------------------------------------------------------------------- 1 | # *agrs 2 | 3 | def add(*number): 4 | sum=0 5 | for i in range(len(number)): 6 | sum+=number[i] 7 | print(sum) 8 | 9 | add(10,5) 10 | add(10,5,6) 11 | -------------------------------------------------------------------------------- /Phase2/Functions/EP7.py: -------------------------------------------------------------------------------- 1 | # Keyword Arguments 2 | 3 | def displayData(fname,lname,city): 4 | print("ชื่อ = ",fname) 5 | print("นามสกุล = ",lname) 6 | print("จังหวัด = ",city) 7 | 8 | # displayData("ระยอง","ใจดี","นัท") 9 | displayData(city="ระยอง",lname="ใจดี",fname="นัท") 10 | displayData(lname="หล่อมาก",city="พะเยา",fname="สมชาย") -------------------------------------------------------------------------------- /Phase2/Functions/EP8.py: -------------------------------------------------------------------------------- 1 | # Default Parameter 2 | 3 | def displayFruit(item): 4 | for i in range(len(item)): 5 | print("ผลไม้ชิ้นที่ ",i+1 ," = " , item[i]) 6 | 7 | def displayVet(item): 8 | for i in range(len(item)): 9 | print("ผักชนิดที่ ",i+1 ," = " , item[i]) 10 | 11 | fruit=["มะม่วง","มะละกอ","ฝรั่ง","มะนาว"] 12 | vet=('ชะอม','ผักกาด','คะน้า') 13 | 14 | displayFruit(vet) 15 | # displayVet(vet) 16 | -------------------------------------------------------------------------------- /Phase2/Functions/EP9.py: -------------------------------------------------------------------------------- 1 | # function return ค่า 2 | 3 | def randomNumber(x): 4 | if len(x)<3 : 5 | return 6 | 7 | if x == "100": 8 | print("ถูกหวย") 9 | return 1000 10 | else : 11 | print("ไม่ถูกหวย") 12 | return 0 13 | 14 | 15 | money=randomNumber("100") 16 | print("เงินรางวัล = ",money) -------------------------------------------------------------------------------- /Phase2/Functions/python-recursion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Phase2/Functions/python-recursion.png -------------------------------------------------------------------------------- /Phase2/SetOperator.py: -------------------------------------------------------------------------------- 1 | # frozen set 2 | fruit=frozenset(["มะม่วง","มะยม","มะนาว"]) 3 | # fruit.add("ทุเรียน") 4 | # fruit.discard("มะยม") 5 | for item in fruit: 6 | print("ข้อมูล=>",item) -------------------------------------------------------------------------------- /Phase2/Settutorial.py: -------------------------------------------------------------------------------- 1 | #แบบปกติ 2 | fruit={"มะม่วง","มะขาม","มะยม"} 3 | 4 | #เพิ่มข้อมูลสมาชิก 5 | fruit.add("ทุเรียน") 6 | fruit.add("สัปปะรด") 7 | fruit.add(999) 8 | #เพิ่มสมาชิกหลายตัว 9 | fruit.update(["ตะไคร้","โหระพา","ชะอม"]) 10 | 11 | #Loop 12 | print(fruit) 13 | 14 | #แสดงจำนวนสมาชิกใน set 15 | # print(len(fruit)) 16 | 17 | fruit.discard("ทุเรียน") # remove / discard 18 | del fruit 19 | print(fruit) -------------------------------------------------------------------------------- /Phase3/Exception/Balance.py: -------------------------------------------------------------------------------- 1 | #โปรแกรมบัญชีธนาคาร 2 | 3 | #data 4 | account={"นายA":5000,"นายB":0} 5 | 6 | def getBalance(): 7 | print("ยอดเงินคงเหลือในบัญชี :",account) 8 | 9 | def deposit(money): 10 | if not type(money) is int and not type(money) is float: 11 | raise Exception("ต้องป้อนตัวเลขเท่านั้นนะครับ") 12 | if money<=0: 13 | raise Exception ("ค่าตัวเลขต้องเป็นบวกเท่านั้น") 14 | print("ฝากเงินเข้าบัญชี A :",money) 15 | account["นายA"]+=money 16 | 17 | def withdraw(money): 18 | if not type(money) is int: 19 | raise Exception("ต้องป้อนตัวเลขเท่านั้นนะครับ") 20 | if money<=0: 21 | raise Exception ("ค่าตัวเลขต้องเป็นบวกเท่านั้น") 22 | if money>account["นายA"]: 23 | raise Exception ("ยอดเงินในบัญชีไม่พอ") 24 | 25 | print("ถอนเงินจากบัญชี A:",money) 26 | account["นายA"]-=money 27 | 28 | def transfer(money): 29 | if not type(money) is int and not type(money) is float: 30 | raise Exception("ต้องป้อนตัวเลขเท่านั้นนะครับ") 31 | if money<=0: 32 | raise Exception ("ค่าตัวเลขต้องเป็นบวกเท่านั้น") 33 | if money>account["นายA"]: 34 | raise Exception ("ยอดเงินในบัญชีไม่พอ") 35 | print("ทำการโอนเงินไปที่บัญชี B :",money) 36 | account["นายB"]+=money 37 | account["นายA"]-=money 38 | 39 | 40 | try: 41 | getBalance() 42 | transfer(500.12) 43 | getBalance() 44 | except Exception as e: 45 | print(e) -------------------------------------------------------------------------------- /Phase3/Exception/EP1.py: -------------------------------------------------------------------------------- 1 | # #Exception 2 | while True: 3 | try: 4 | name=input("ป้อนชื่อผู้ใช้โปรแกรม :") 5 | if name == "ก้อง": 6 | raise Exception("มีชื่อในระบบแล้วนะครับ") 7 | 8 | number1=int(input("ป้อนตัวเลข 1 :")) 9 | number2=int(input("ป้อนตัวเลข 2 :")) 10 | if number1 == 0 and number2 == 0: 11 | break 12 | if number1<0 or number2<0: 13 | raise Exception("ไม่สามารถป้อนค่าติดลบได้นะครับ") 14 | 15 | result=number1/number2 16 | print(result) 17 | except Exception as e: 18 | print(e) 19 | 20 | #ValueError => ค่าผิดพลาด 21 | #ZeroDivisionError -------------------------------------------------------------------------------- /Phase3/File/EP2.py: -------------------------------------------------------------------------------- 1 | import os 2 | try: 3 | if os.path.exists("Score.txt"): 4 | os.remove("Score.txt") 5 | print("ลบแล้วนะครับ") 6 | else : 7 | print("ไม่พบไฟล์นี้ครับผม") 8 | except Exception as e: 9 | print(e) -------------------------------------------------------------------------------- /Phase3/File/Grade.txt: -------------------------------------------------------------------------------- 1 | s01 50 C 2 | s02 70 B 3 | s03 65 C 4 | s04 80 A 5 | s05 40 F 6 | s06 100 A 7 | -------------------------------------------------------------------------------- /Phase3/File/Score.txt: -------------------------------------------------------------------------------- 1 | s01 50 2 | s02 70 3 | s03 65 4 | s04 80 5 | s05 40 6 | s06 100 -------------------------------------------------------------------------------- /Phase3/File/StudentGrade.py: -------------------------------------------------------------------------------- 1 | try: 2 | # fw=open("Score.txt","a",encoding="utf-8") 3 | # while True: 4 | # studentid=input("ป้อนรหัสนักเรียน:") 5 | # if studentid == "exit": 6 | # break 7 | # score=input("ป้อนคะแนนสอบ:") 8 | # fw.writelines(studentid+"\t"+score+"\n") 9 | # fw.close() 10 | fr=open("Score.txt","r",encoding="utf-8") 11 | fw=open("Grade.txt","w",encoding="utf-8") 12 | grade=None 13 | for line in fr.readlines(): 14 | score=line[-4:].strip() # คะแนนนักเรียน 15 | studentid=line[:-4].strip() # รหัสนักเรียน 16 | # print("รหัส = ",studentid," คะแนน = ",score) 17 | score=int(score) 18 | if score>=80: 19 | grade="A" 20 | elif score>=70 and score<80: 21 | grade="B" 22 | elif score>=50 and score<=69: 23 | grade="C" 24 | else: 25 | grade="F" 26 | fw.writelines(studentid+"\t"+str(score)+"\t"+grade+"\n") 27 | fw.close() 28 | fr.close() 29 | 30 | except Exception as e: 31 | print(e) -------------------------------------------------------------------------------- /Phase3/Module/MainProgram.py: -------------------------------------------------------------------------------- 1 | # โปรแกรมหลัก 2 | from MyCalculate.CalculateService import addition 3 | from Mypackage.Weather import city 4 | addition(10,5,20) 5 | print(city) -------------------------------------------------------------------------------- /Phase3/Module/MainProgram2.py: -------------------------------------------------------------------------------- 1 | from Mypackage.Weather import city 2 | 3 | print(city) -------------------------------------------------------------------------------- /Phase3/Module/MyCalculate/CalculateService.py: -------------------------------------------------------------------------------- 1 | 2 | #ให้บริการข้อมูลค่าคงที่ / คำนวณตัวเลข 3 | PI=3.14 4 | ROOT = 1.414 5 | 6 | def addition(*args): 7 | total=0 8 | for i in range(len(args)): 9 | total+=args[i] 10 | print("หาผลบวก = ", total) 11 | 12 | def subtraction(num1,num2): 13 | print("ผลลบ = ", (num1-num2)) 14 | 15 | def power(num1,m): 16 | print("ผลการยกกำลัง = ",num1**m) -------------------------------------------------------------------------------- /Phase3/Module/MyCalculate/__pycache__/CalculateService.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Phase3/Module/MyCalculate/__pycache__/CalculateService.cpython-38.pyc -------------------------------------------------------------------------------- /Phase3/Module/Mypackage/Weather.py: -------------------------------------------------------------------------------- 1 | city={ 2 | "ชลบุรี":"ฝนตก", 3 | "ระยอง":"แดดร้อน" 4 | } 5 | 6 | 7 | def getWeather(): 8 | print(city) -------------------------------------------------------------------------------- /Phase3/Module/Mypackage/__pycache__/CalculateService.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Phase3/Module/Mypackage/__pycache__/CalculateService.cpython-38.pyc -------------------------------------------------------------------------------- /Phase3/Module/Mypackage/__pycache__/Weather.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Phase3/Module/Mypackage/__pycache__/Weather.cpython-38.pyc -------------------------------------------------------------------------------- /Phase3/Utility Module/Crackpassword.py: -------------------------------------------------------------------------------- 1 | # รหัส ATM = 132 2 | import random 3 | 4 | ATM_PASSWORD="ko6" 5 | result="" #สำหรับเก็บผลลัพธ์ 6 | 7 | while result!=ATM_PASSWORD : 8 | result="" 9 | for letter in range(len(ATM_PASSWORD)): 10 | list_number=random.choice("0123456789abcdefghijklmnopqrstuvwxyz") 11 | result="".join(list_number)+str(result) 12 | print("SEARCH = ",result) 13 | print("CRACK PASSWORD IS ", result) -------------------------------------------------------------------------------- /Phase3/Utility Module/EP1 Date-Time.py: -------------------------------------------------------------------------------- 1 | # Module Date / Time 2 | import datetime 3 | 4 | result=datetime.datetime.now() # ดึงวัน/เวลาปัจจุบันมาใช้งาน 5 | # print(result.year) # เอาปีมาแสดง 6 | # print(result.month) # เอาเดือนมาแสดง 7 | 8 | newdate=datetime.datetime(2020,6,20,15) # yyyy,m,d 9 | # print(newdate) 10 | 11 | #รูปแบบแสดงผล 12 | print("เริ่มต้น = ",result) 13 | print(result.strftime("%x")) # m/d/y สั้น 14 | print(result.strftime("%X")) #เวลา time 15 | print(result.strftime("%c")) 16 | 17 | #เวลา 18 | print(result.strftime("%H:%M:%S %p")) 19 | 20 | #1 - 366 21 | print(result.strftime("%j")) 22 | 23 | # date 24 | print(result.strftime("%a")) # แบบสั้น 25 | print(result.strftime("%A")) # แบบเต็ม 26 | print(result.strftime("%w")) # 0 = sunday 27 | print(result.strftime("%d")) # วันที่ 28 | print(result.strftime("%b")) #เดือนแบบสั้น 29 | print(result.strftime("%B")) #เดือนแบบชื่อเต็ม 30 | 31 | print(result.strftime("วัน %A ประจำวันที่ %d เดือน %B ปี %Y")) 32 | 33 | # ว/ด/ป 34 | print(result.strftime("%d / %m / %Y")) 35 | -------------------------------------------------------------------------------- /Phase3/Utility Module/EP2 Math-Utill.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | #ค่าทางตรีโกณมิติ 4 | convert=math.radians(30) # degrees => radians 5 | x=math.tan(convert) # radians 6 | # print(x) 7 | 8 | point1=[5,4] 9 | point2=[5,13] 10 | 11 | #คำนวณระยะทางจากจุด 1 => 2 12 | d=math.dist(point1,point2) 13 | # print(d) 14 | 15 | #ลอการิทึม 16 | l1=math.log2(32) 17 | print(l1) -------------------------------------------------------------------------------- /Phase3/Utility Module/EP3 Random-Utill.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | for i in range(15): 4 | x=random.choice("0123456789") 5 | print(x) -------------------------------------------------------------------------------- /Phase3/__pycache__/Calculate.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Phase3/__pycache__/Calculate.cpython-38.pyc -------------------------------------------------------------------------------- /Phase3/__pycache__/CalculateService.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Phase3/__pycache__/CalculateService.cpython-38.pyc -------------------------------------------------------------------------------- /Phase3/__pycache__/Weather.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kongruksiamza/PythonBeginner/2665c38966c6e3639471fff4392dbeaeea9f8701/Phase3/__pycache__/Weather.cpython-38.pyc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | [![Youtube KongRuksiam Tutorial](https://youtube-stats-card.vercel.app/api?channelid=UCB6eDEzpqpiaZnDMzoje57Q&layout=extruded&theme=dark)](https://www.youtube.com/@KongRuksiamTutorial) 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | kongruksiamza 26 | 27 |
28 | 29 | --- 30 | 31 | ## 🎓 คอร์สเรียนที่น่าสนใจ [![Udemy](https://img.shields.io/badge/Udemy-A435F0?logo=udemy&logoColor=fff)](https://www.udemy.com/user/kong-ruksiam/) 32 | - [สร้างแอพพลิเคชั่นด้วยภาษา Python (Real-World Projects)](https://www.udemy.com/course/python-real-world-projects/?referralCode=4D6784B6C4CF2CBB1892) 33 | - [สร้าง GUI Application ด้วย Python](https://www.udemy.com/course/python-gui-projects/?referralCode=CFE6A91D21C759EF13E1) 34 | - [พัฒนาเว็บด้วย Django Framework 4.x](https://www.udemy.com/course/django-framework-real-world-projects/?referralCode=63ED08A516BE8C4A93F7) 35 | - [พัฒนาระบบร้านค้าออนไลน์ด้วย Django Framework 4.x](https://www.udemy.com/course/django-framework-e-commerce/?referralCode=AFDB5F462F46815300C1) 36 | - [พัฒนา REST API ด้วย Django REST Framework](https://www.udemy.com/course/rest-api-django-rest-framework/?referralCode=3E81004F9DAE23131BC4) 37 | -------------------------------------------------------------------------------- /String: -------------------------------------------------------------------------------- 1 | การเข้าถึงตัวอักษรใน string 2 | len function 3 | ลบช่องว่างซ้ายขวา (strip) 4 | แปลง case ของ string 5 | การแทนที่ 6 | การเช็คข้อความ => true , false 7 | การต่อ String (Concatinate) + 8 | การจัดรูปแบบการแสดงผล format + {} 9 | นับจำนวนคำในประโยค (count) 10 | เช็คคำขึ้นต้น / เช็คคำลงท้าย --------------------------------------------------------------------------------