2
3
“Beginner to Expert”
4
Data Science
Automatic System Web scraping
Internet of Things Python Web Development
Algorithmic Trading Social Network API
Microsoft Office Game Development
5
“All Level”
6
Facebook Group
7
Facebook Group
8
Introduction
ประวัติความเป็นมาของ Python
Guido Van Rossum
10
ประวัติความเป็นมาของ Python
11
ข้อดีของ Python มีอะไรบ้าง ?
Ref: https://www.facebook.com/tautologyai/posts/2987242824730932
12
Python ถูกนาไปใช้ท่ไี หนบ้าง ?
13
วิธีการติดตั้งใช้งาน Python
14
Print Command
Print Command
1. Print String
2. Print Numeric
3. Print String + Numeric
16
1. Print String
1.1 Quote
1.2 Double Quote
1.3 Multiple Line
1.4 String with Quotation Marks
1.5 String with Backslash
17
1.1 Quote
18
1.2 Double Quote
19
1.3 Multiple Line
20
1.3 Multiple Line
21
1.4 String with Quotation Marks
1.4.1 String with Quote
1.4.2 String with Double Quote
22
1.4.1 String with Quote
23
1.4.2 String with Double Quote
24
1.5 String with Backslash
25
Print Command
1. Print String
2. Print Numeric
3. Print String + Numeric
26
2. Print Numeric
2.1 Numeric
2.2 %d %f %s
27
2.1 Numeric
28
2.2 %d %f %s
29
2.2 %d %f %s
30
2.2 %d %f %s
31
Print Command
1. Print String
2. Print Numeric
3. Print String + Numeric
32
3. Print String + Numeric
3.1 Comma
3.2 String Concatenation
3.3 %d %f %s
33
3.1 Comma
34
3.2 String Concatenation
35
3.3 %d %f %s
36
Print Command
1. Print String
2. Print Numeric
3. Print String + Numeric
37
Variable
Variable
1. Create & Assign
2. Create Multiple Variable
3. Identifier
39
1. Create & Assign
40
1. Create & Assign
41
Variable
1. Create & Assign
2. Create Multiple Variable
3. Identifier
42
2. Create Multiple Variable
43
2. Create Multiple Variable
44
Variable
1. Create & Assign
2. Create Multiple Variable
3. Identifier
45
3. Identifier
3.1 Character & Underscore First
3.2 Case Sensitive
3.3 No Special Character
3.4 Reversed Word
46
3.1 Character & Underscore First
47
3.1 Character & Underscore First
48
3.2 Case sensitive
49
Special Character
“
{}[]!@#$%^
&*()-=/|\.<>
50
3.3 No Special Character
51
3.3 No Special Character
52
3.3 No Special Character
53
Reserved Word
“
and, assert, break, class, continue, def,
del, elif, else, except, exec, finally, for, from,
global, if, import, in, is, lambda, not, or,
pass, print, raise, return, try, while, yield
54
3.4 Reserved Word
55
3.4 Reserved Word
56
3.4 Reserved Word
57
Variable
1. Create & Assign
2. Create Multiple Variable
3. Identifier
58
Data Structure
Data Structure
1. Basic Data Structure
2. Composite Data Structure
60
1. Basic Data Structure
1.1 Numeric
1.2 String
61
1.1 Numeric
1.1.1 Integer
1.1.2 Floating-Point Number
1.1.3 Boolean
1.1.4 Complex Number
62
1.1.1 Integer
63
1.1.2 Floating-Point Number
64
1.1.3 Boolean
65
1.1.4 Complex Number
66
1. Basic Data Type
1.1 Numeric
1.2 String
67
1.2 String
1.2.1 Create String
1.2.2 Read String
1.2.3 String + replace
1.2.4 String + len
1.2.5 String + in
1.2.6 String + split
1.2.7 String + Concatenation
68
1.2.1 Create String
69
1.2.2 Read String
70
1.2.2 Read String
71
1.2.3 String + replace
72
1.2.4 String + len
73
1.2.5 String + in
74
1.2.6 String + split
75
1.2.7 String + Concatenation
76
1.2.7 String + Concatenation
77
1. Basic Data Structure
1.1 Numeric
1.2 String
78
Data Structure
1. Basic Data Structure
2. Composite Data Structure
79
2. Composite Data Structure
2.1 List
2.2 Tuple
2.3 Dictionary
2.4 Set
80
List
CRUD + sort + len + in
81
2.1 List
2.1.1 Create List
2.1.2 Read List
2.1.3 Update List
2.1.4 Delete List
2.1.5 List + sort
2.1.6 List + len
2.1.7 List + in
82
2.1.1 Create List
83
2.1.2 Read List
84
2.1.2 Read List
85
2.1.3 Update List : Replace
86
2.1.3 Update List : append
87
2.1.3 Update List : extend
88
2.1.3 Update List : insert
89
2.1.4 Delete List : del
90
2.1.4 Delete List : del
91
2.1.4 Delete List : remove
92
2.1.4 Delete List : clear
93
2.1.5 List + sort
94
2.1.5 List + sort
95
2.1.5 List + sort
96
2.1.5 List + sort
97
2.1.7 List + len
98
2.1.5 List + in
99
2. Composite Data Structure
2.1 List
2.2 Tuple
2.3 Dictionary
2.4 Set
100
Tuple
CRUD + len + in
101
2.2 Tuple
2.2.1 Create Tuple
2.2.2 Read Tuple
2.2.3 Tuple + len
2.2.4 Tuple + in
102
2.2.1 Create Tuple
103
2.2.2 Read Tuple
104
2.2.2 Read Tuple
105
2.2.3 Tuple + len
106
2.2.4 Tuple + in
107
2. Composite Data Structure
2.1 List
2.2 Tuple
2.3 Dictionary
2.4 Set
108
Dictionary
CRUD + len + in
109
2.3 Dictionary
2.1.1 Create Dictionary
2.1.2 Read Dictionary
2.1.3 Update Dictionary
2.1.4 Delete Dictionary
2.1.5 Dictionary + len
2.1.6 Dictionary + in
110
2.3.1 Create Dictionary
111
2.3.2 Read Dictionary
112
2.3.3 Update Dictionary : Replace
113
2.3.3 Update Dictionary : Add
114
2.3.3 Update Dictionary : update
115
2.3.4 Delete Dictionary : del
116
2.3.4 Delete Dictionary : clear
117
2.3.5 Dictionary + len
118
2.3.6 Dictionary + in
119
2.3.6 Dictionary + in
120
2. Composite Data Structure
2.1 List
2.2 Tuple
2.3 Dictionary
2.4 Set
121
Set
CRUD + len + in
122
Set
+ union
+ intersection
+ difference
+ Symmetric Difference
123
2.4 Set
2.4.1 Create Set
2.4.2 Read Set
2.4.3 Update Set
2.4.4 Delete Set
2.4.5 Set + len
2.4.6 Set + in
124
2.4 Set
2.4.7 Set + Union
2.4.8 Set + Intersection
2.4.9 Set + Difference
2.4.10 Set + Symmetric Difference
125
2.4.1 Create Set
126
2.4.2 Read Set
127
2.4.3 Update Set : add
128
2.4.3 Update Set : update
129
2.4.4 Delete Set : remove
130
2.4.4 Delete Set : clear
131
2.4.5 Set + len
132
2.4.6 Set + in
133
2.4.7 Set + Union
134
2.4.8 Set + Intersection
135
2.4.9 Set + Difference
136
2.4.10 Set + Symmetric Difference
137
2. Composite Data Structure
2.1 List
2.2 Tuple
2.3 Dictionary
2.4 Set
138
Data Structure
1. Basic Data Structure
2. Composite Data Structure
139
List Tuple Dictionary Set
Create listA=[]
listB=[1, 2, 3]
tupleA=()
tupleB=(1, 2, 3)
dictA={} setA=set()
dictB={‘key’:value} setB={1, 2, 3}
Read listB[start] tupleB[start]
listB[start:end] tupleB[start:end]
dictB[‘key’] for b in setB:
print(b)
140
Replace
append
insert
Update extend
add
update
141
List Tuple Dictionary Set
del
Delete remove
clear
len len(listB) len(tupleB) len(dictB) len(setB)
‘a’ in ‘a’ in ‘keyA’ in
in ‘a’ in setB
listB tupleB dictB
142
Set
Union (|)
Intersection (&)
Difference (-)
Symmetric Difference
(^)
143
Operator
Operator
𝟐
𝒚 = 𝒙 + 𝟐𝒙 + 𝟏
▪ 𝒚, 𝒙, 𝟏 คือ ตัวถูกดำเนินกำร (Operand)
▪ =, + คือ ตัวดำเนินกำร (Operator)
▪ 𝒚 = 𝒙𝟐 + 𝟐𝒙 + 𝟏 ทั้งหมด คือ นิพจน์ (expression)
145
Operator
1. Arithmetic Operators
2. Comparison Operators
3. Logical Operators
4. Membership Operators
5. Operator Precedence
146
1. Arithmetic Operators
1.1 บวก (+)
1.2 ลบ (-)
1.3 คูณ (*)
1.4 หำร (/)
1.5 ยกกำลัง (**)
1.6 เศษจำกำรหำร (%)
1.7 ผลหำรปัดเศษลง (//)
147
1.1 บวก (+)
148
1.2 ลบ (-)
149
1.3 คูณ (*)
150
1.4 หาร (/)
151
1.5 ยกกาลัง (**)
152
1.6 เศษจาการหาร (%)
153
1.7 ผลหารปัดเศษลง (//)
154
Operator
1. Arithmetic Operators
2. Comparison Operators
3. Logical Operators
4. Membership Operators
5. Operator Precedence
155
2. Comparison Operators
2.1 ตรวจสอบควำมเท่ำกัน (==)
2.2 ตรวจสอบควำมไม่เท่ำกัน (!=)
2.3 ตรวจสอบควำมมำกกว่ำ (>)
2.4 ตรวจสอบควำมน้อยกว่ำ (<)
2.5 ตรวจสอบควำมมำกกว่ำหรือเท่ำกับ (>=)
2.6 ตรวจสอบควำมน้อยกว่ำหรือเท่ำกับ (<=)
156
2.1 ตรวจสอบความเท่ากัน (==)
157
2.2 ตรวจสอบความไม่เท่ากัน (!=)
158
2.3 ตรวจสอบความมากกว่า (>)
159
2.4 ตรวจสอบความน้อยกว่า (<)
160
2.5 ตรวจสอบความมากกว่าหรือเท่ากับ (>=)
161
2.6 ตรวจสอบความน้อยกว่าหรือเท่ากับ (<=)
162
Operator
1. Arithmetic Operators
2. Comparison Operators
3. Logical Operators
4. Membership Operators
5. Operator Precedence
163
3. Logical Operators
3.1 and
3.2 or
3.3 not
164
3.1 and
p q p and q
True True True
True False False
False True False
False False False
165
3.1 and
166
3.2 or
p q p or q
True True True
True False True
False True True
False False False
167
3.2 or
168
3.3 not
p not p
True False
False True
169
3.3 not
170
Operator
1. Arithmetic Operators
2. Comparison Operators
3. Logical Operators
4. Membership Operators
5. Operator Precedence
171
4. Comparison Operators
4.1 in
4.2 not in
172
4.1 in
173
4.1 in
174
4.2 not in
175
4.2 not in
176
Operator
1. Arithmetic Operators
2. Comparison Operators
3. Logical Operators
4. Membership Operators
5. Operator Precedence
177
5. Operators Precedence
()
**
*, /, %, //
+, -
<=, <, >, >=
==, !=
=
178
Operator
1. Arithmetic Operators
2. Comparison Operators
3. Logical Operators
4. Membership Operators
5. Operator Precedence
179
Flowchart
Flowchart
เริ่ม, จบ พิ มพ์
กำรประกำศตัวแปร เงื่อนไข
กำรคำนวน (if-else)
รับอินพุ ต
181
Flowchart
Ex 1. start
True False
ถ้ำถูกหวย
เลี้ยงทั้งซอย เงียบ
end
182
Flowchart
Ex 2. start
True False
ถ้ำฝนไม่ตก
‘เป็นวันที่ดี’ ‘อย่ำลืมพกร่ม’
end
183
If-Else
If-Else
1. If
2. If-Else
3. If-Elif
4. If-Elif-Else
185
1. If
186
1. If
187
start
name
True False
1. If
name == ‘John’
‘Hi John’
‘Nice to meet you’
end
188
If-Else
1. If
2. If-Else
3. If-Elif
4. If-Elif-Else
189
2. If-Else
190
2. If-Else
191
2. If-Else
start
score
True False
Score >= 50
‘Pass’ ‘Fail’
end
192
If-Else
1. If
2. If-Else
3. If-Elif
4. If-Elif-Else
193
3. If-Elif
194
3. If-Elif
195
3. If-Elif
196
3. If-Elif
start
name
True False
name == ‘Alan
Turing’
True False
‘Oh God !’ name == ‘Isac
Newton’
‘OMG !’
‘Glad to
see you’
end
197
If-Else
1. If
2. If-Else
3. If-Elif
4. If-Elif-Else
198
4. If-Elif-Else
199
4. If-Elif-Else
200
4. If-Elif-Else
201
4. If-Elif-Else
202
4. If-Elif-Else
start
name
True False
name ==
‘Gift’
‘I miss True False
name ==
you’
‘Cherry’
‘I love True False
name ==
you’ ‘Wine’
‘I need ‘Leave me
you’ alone’
end
203
If-Else
1. If
2. If-Else
3. If-Elif
4. If-Elif-Else
204
For & While Loop
For & While Loop
1. For
2. While
3. Loop & Statement
206
1. For
1.1 Standard For
1.2 For + String
1.3 For + List
1.4 For + Tuple
1.5 For + Dictionary
1.6 For + Set
207
1.1 Standard For
1.1.1 for i in range (end)
1.1.2 for i in range (start, end)
1.1.3 for i in range (start, end, step)
208
1.1.1 for i in range (end)
209
1.1.2 for i in range (start, end)
210
1.1.3 for i in range (start, end, step)
211
1.2 For + String
212
1.2 For + String
213
1.2 For + String
214
1.2 For + String
215
1.3 For + List
216
1.3 For + List
217
1.3 For + List
218
1.3 For + List
219
1.4 For + Tuple
220
1.4 For + Tuple
221
1.4 For + Tuple
222
1.4 For + Tuple
223
1.5 For + Dictionary
224
1.5 For + Dictionary
225
1.5 For + Dictionary
226
1.6 For + Set
227
For & While Loop
1. For
2. While
3. Loop & Statement
228
2. While
229
2. While
230
2. While
231
For & While Loop
1. For
2. While
3. Loop & Statement
232
1. Loop & Statement
3.1 break
3.2 continue
3.3 pass
233
3.1 break
234
3.2 continue
235
3.3 pass
236
3.3 pass
237
For & While Loop
1. For
2. While
3. Loop & Statement
238
Function
ทาไมต้องใช้ Function
Ex. list1 = [1, 3, 4, 7, 11]
list2 = [4, 3, 2, 1, 0]
อยำกหำผลรวมของ list1
อยำกหำผลรวมของ list2
240
ทาไมต้องใช้ Function
Ex.
sum1 = 0
for i in range(len(list1)):
sum1 = sum1+listi[i]
sum2
for i in range(len(list2)):
sum2 = sum2+list2[i]
241
ทาไมต้องใช้ Function
Ex. list1 = [1, 3, 4, 7, 11]
⋮
listN = [7, 5, 12, 4, 0]
อยำกหำผลรวมของ list1
⋮
อยำกหำผลรวมของ listN
242
ทาไมต้องใช้ Function
243
ทาไมต้องใช้ Function
Ex.
def Sum(list):
sumx = 0
for i in range(len(list)):
sumx = sumx + list[i]
return sumx
244
ทาไมต้องใช้ Function
Ex. Sum1 = Sum(list1)
sum2 = Sum(list2)
⋮
sumN = Sum(listN)
245
Function
1. With Parameter
2. Without Parameter
246
1. With Parameter
247
1. With Parameter
248
1. With Parameter
249
Function
1. With Parameter
2. Without Parameter
250
2. Without Parameter
251
2. Without Parameter
252
Function
1. With Parameter
2. Without Parameter
253
OOP
ทาความรู้จัก OOP
1. OOP เป็นเทคนิคการเขียนโปรแกรมแบบหนึ่ง ทีม
่ องทุกอย่างเป็น
Object
2. การเขียน Code แบบ OOP ทาให้ง่าย & เป็นระเบียบ ในการ
พั ฒนา/ปรับปรุง
255
OOP
1. Attribute
2. Method
256
1. Attribute
257
1. Attribute
258
1. Attribute
259
1. Attribute
260
OOP
1. Attribute
2. Method
261
2. Method
262
2. Method
263
OOP
1. Attribute
2. Method
264