PITCHME.md 6.16 KB
Newer Older
Bodor Máté's avatar
v0.13    
Bodor Máté committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Python3  

```python
import this
```

---

### The Zen of Python, by Tim Peters

<div class="half left">
  <ol>
  @size[24px](<li><b>Beautiful is better than ugly.</b></li>)
  @size[24px](<li><b>Explicit is better than implicit.</b></li>)
  @size[24px](<li><b>Simple is better than complex.</b></li>)
  @size[24px](<li><b>Complex is better than complicated.</b></li>)
  @size[24px](<li>Flat is better than nested.</li>)
  @size[24px](<li>Sparse is better than dense.</li>)
  @size[24px](<li><b>Readability counts.</b></li>)
  @size[24px](<li>Special cases aren't special enough to break the rules.</li>)
  @size[24px](<li>Although practicality beats purity.</li>)
  @size[24px](<li>Errors should never pass silently.</li>)
  @size[24px](<li>Unless explicitly silenced.</li>)
  @size[24px](<li>In the face of ambiguity, refuse the temptation to guess.</li>)
  </ol>
</div>

<div class="half right">
  <ol start="13">
  @size[24px](<li>There should be one-- and preferably only one --obvious way to do it.</li>)
  @size[24px](<li>Although that way may not be obvious at first unless you're Dutch.</li>)
  @size[24px](<li>Now is better than never.</li>)
  @size[24px](<li>Although never is often better than <i>right</i> now.</li>)
  @size[24px](<li><b>If the implementation is hard to explain, it's a bad idea.</b></li>)
  @size[24px](<li><b>If the implementation is easy to explain, it may be a good idea.</b></li>)
  @size[24px](<li>Namespaces are one honking great idea -- let's do more of those!</li>)
  </ol>
</div>

Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
40
41
42
43
44

---

### Története

Bodor Máté's avatar
v0.01    
Bodor Máté committed
45
 - Guido van Rossum
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
46

Bodor Máté's avatar
v0.01    
Bodor Máté committed
47
 - 1991-ben jött létre
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
48

Bodor Máté's avatar
v0.01    
Bodor Máté committed
49
 - Magas szintű programozási nyelv
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
50

Bodor Máté's avatar
v0.03    
Bodor Máté committed
51
52
53
54
55
56
Note:
   - BDFL (Benevolent dictator for life)
   - Monty Python, karácsony
   - könnyen olvasható, tanulható, gyors fejlesztés
   - lassú

Bodor Máté's avatar
v0.01    
Bodor Máté committed
57
---
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
58
59
60

### Interpretált

Bodor Máté's avatar
v0.03    
Bodor Máté committed
61
62
63
 - A kódot egy értelmező dolgozza fel
 - Nem kell fordítani
 - Platformfüggetlen
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
64

Bodor Máté's avatar
v0.03    
Bodor Máté committed
65
Note:
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
66

Bodor Máté's avatar
v0.03    
Bodor Máté committed
67
---
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
68

Bodor Máté's avatar
v0.03    
Bodor Máté committed
69
### Miért szeretjük a python?
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
70

Bodor Máté's avatar
v0.03    
Bodor Máté committed
71
72
73
Note:
   - Magasszintű:
      -  Könnyen tanulható, gyors fejlesztés
Bodor Máté's avatar
v0.04    
Bodor Máté committed
74
75
   - Interpretált:
      - Bárhol lefut, nem kell lefordítani
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
76

Bodor Máté's avatar
v0.03    
Bodor Máté committed
77
---
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
78

Bodor Máté's avatar
v0.09    
Bodor Máté committed
79
![Python is awsome!](https://cdn-images-1.medium.com/max/800/0*_e09A-2xg4x7PG_A.)
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
80

Bodor Máté's avatar
v0.04    
Bodor Máté committed
81
---
Bodor Máté's avatar
v0.07    
Bodor Máté committed
82
83
84
85
86
87
88
89
90
91
92
93
94

### Tökéletes?!

+++
### Tökéletes?!

NEM!

+++

### Tökéletes?!
- Lassú, nagyon lassú
- Zabálja a ramot
Bodor Máté's avatar
v0.13    
Bodor Máté committed
95

Bodor Máté's avatar
v0.07    
Bodor Máté committed
96
97
98
99
100
101
102
103
104

Note:

+++
Kép: https://benchmarksgame-team.pages.debian.net/benchmarksgame/faster/gpp-python3.html

Note:
 https://en.wikipedia.org/wiki/N-body_simulation
---
Bodor Máté's avatar
v0.04    
Bodor Máté committed
105
106
### Csomagok

Bodor Máté's avatar
v0.06    
Bodor Máté committed
107
108
109
110
- Webfejlesztés:
    - Django
    - Flusk
    - Requests
Bodor Máté's avatar
v0.05    
Bodor Máté committed
111
112
113

+++

Bodor Máté's avatar
v0.06    
Bodor Máté committed
114
115
116
- IT Security:
    - Scapy
    - Nmap
Bodor Máté's avatar
v0.05    
Bodor Máté committed
117
118
119

+++

Bodor Máté's avatar
v0.06    
Bodor Máté committed
120
121
122
- AI:
    - TensorFlow
    - Keras
Bodor Máté's avatar
v0.05    
Bodor Máté committed
123
124
125

+++

Bodor Máté's avatar
v0.06    
Bodor Máté committed
126
127
128
129
- Data Science:
    - Pandas
    - StatsModels
    - NumPy
Bodor Máté's avatar
v0.05    
Bodor Máté committed
130
131
132

+++

Bodor Máté's avatar
v0.06    
Bodor Máté committed
133
134
135
136
- GUI:
    - PyQt
    - Tkinter
    - Flexx
Bodor Máté's avatar
v0.04    
Bodor Máté committed
137
 
Bodor Máté's avatar
v0.05    
Bodor Máté committed
138
+++
Bodor Máté's avatar
v0.06    
Bodor Máté committed
139
140
141
142
- Data visualization
    - matplotlib
    - Plotly
    - geoplotlib
Bodor Máté's avatar
v0.03    
Bodor Máté committed
143
Note:
Bodor Máté's avatar
v0.04    
Bodor Máté committed
144
145
   

Bodor Máté's avatar
v0.13    
Bodor Máté committed
146

Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
147
148
149
150
---

### Pip

Bodor Máté's avatar
v0.01    
Bodor Máté committed
151
 - csomagkezelő
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
152

Bodor Máté's avatar
v0.01    
Bodor Máté committed
153
  - egy helyen van minden
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
154

Bodor Máté's avatar
v0.01    
Bodor Máté committed
155
  - könnyen használható
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
156
157
158
159
160
161

Note:

- könnyen használható
  - C++ ban jóval nehezebb

Bodor Máté's avatar
v0.07    
Bodor Máté committed
162
+++
Bodor Máté's avatar
v0.13    
Bodor Máté committed
163
164
165

```bash
pip install flake8
Bodor Máté's avatar
v0.07    
Bodor Máté committed
166
```
Bodor Máté's avatar
v0.13    
Bodor Máté committed
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

---

### Flake8

- linter
- segít jobb kódot írni:
  - syntax error
  - typo
  - rossz formázás
- pep8

Note:
  pep8:
    - Style Guide
    - átlátható
    - egységes
    - kevesebb merge conflict
Bodor Máté's avatar
v0.07    
Bodor Máté committed
185

Bodor Máté's avatar
v0.01    
Bodor Máté committed
186
---
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
187
188
189

### Virtualenv

Bodor Máté's avatar
v0.13    
Bodor Máté committed
190
191
192
193
194
195
- saját környezet minden projekthez

Note:

- Dependensy, egy csomag több verzió

Bodor Máté's avatar
v0.12    
Bodor Máté committed
196
+++
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
197

Bodor Máté's avatar
v0.13    
Bodor Máté committed
198
199
200
- Windows:

```cmd
Bodor Máté's avatar
v0.07    
Bodor Máté committed
201
202
203
python -m venv venv
```

Bodor Máté's avatar
v0.13    
Bodor Máté committed
204
```cmd
Bodor Máté's avatar
v0.07    
Bodor Máté committed
205
206
venv\Scripts\activate.bat
```
Bodor Máté's avatar
v0.13    
Bodor Máté committed
207

Bodor Máté's avatar
v0.12    
Bodor Máté committed
208
+++
Bodor Máté's avatar
v0.12    
Bodor Máté committed
209

Bodor Máté's avatar
v0.13    
Bodor Máté committed
210
211
212
- Linux:

```bash
Bodor Máté's avatar
v0.07    
Bodor Máté committed
213
214
215
python3 -m venv venv
```

Bodor Máté's avatar
v0.13    
Bodor Máté committed
216
```bash
Bodor Máté's avatar
v0.11    
Bodor Máté committed
217
source venv\bin\activate
Bodor Máté's avatar
v0.07    
Bodor Máté committed
218
219
```

Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
220
221
---

Bodor Máté's avatar
v0.13    
Bodor Máté committed
222
### Hello World
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
223

Bodor Máté's avatar
v0.13    
Bodor Máté committed
224
+++
Bodor Máté's avatar
v0.07    
Bodor Máté committed
225

Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
226
227
228
229
```python
print("Hello World!")
```

Bodor Máté's avatar
v0.07    
Bodor Máté committed
230
+++
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
231

Bodor Máté's avatar
v0.13    
Bodor Máté committed
232
```bash
Bodor Máté's avatar
v0.08    
Bodor Máté committed
233
234
235
pip install colorama
```

Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
236
237
238
239
240
241
242
243
244
245
246
247
```python
from colorama import init
from colorama import Fore, Back, Style

init()
print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background')
print(Style.DIM + 'and in dim text')
print(Style.RESET_ALL)
print('back to normal now')
```

248
249
---

Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
### Szintaxis

```python
#!/usr/bin/python3
import sys

try:
   # open file stream
   file = open(file_name, "w")

except IOError:
   print ("There was an error writing to", file_name)
   sys.exit()
print ("Enter '", file_finish,)
print "' When finished"

while file_text != file_finish:
   file_text = raw_input("Enter text: ")
Bodor Máté's avatar
v0.07    
Bodor Máté committed
268
  
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
269
270
271
272
273
274
275
276
277
278
279
280
```

Note:

- Nincs sorvég jel
- A kód blokkok indentálva vannak nincs kapcsoszárójel
- komment #

---

### Változók

Bodor Máté's avatar
v0.08    
Bodor Máté committed
281
282
+++

Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
283
284
- integer
- float
Bodor Máté's avatar
v0.08    
Bodor Máté committed
285
- complex number
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
286
- string
Bodor Máté's avatar
v0.08    
Bodor Máté committed
287
- bool
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
288

Bodor Máté's avatar
v0.01    
Bodor Máté committed
289
---
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
290
291
292

### List

Bodor Máté's avatar
v0.08    
Bodor Máté committed
293
294
295

+++

Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
296
```python
297
myList = ['physics', 'chemistry', 'physics', 1997, 2000]
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
298
299
300
301
```

bármilyen típus lehet benne

302
módosítható(mutable)
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
303

Bodor Máté's avatar
v0.01    
Bodor Máté committed
304
---
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
305
306

```python
307
308
print ("myList[0]: ", myList[0])
print ("myList[1:5]: ", myList[1:5])
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
309
310
311
```

```python
312
313
myList.append(5)
del myList[2]
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
314
315
```

Bodor Máté's avatar
v0.01    
Bodor Máté committed
316
---
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
317
318
319

### Tuple

Bodor Máté's avatar
v0.08    
Bodor Máté committed
320
321
+++

Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
Ugyanaz, mint egy lista

Nem módosítható(immutable)

```python
tup1 = (12, 34.56)
tup2 = ('abc', 'xyz')
```

```python
# tup1[0] = 100;
tup3 = tup1 + tup2
print (tup3)
```

Bodor Máté's avatar
v0.01    
Bodor Máté committed
337
---
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
338
339
340

### Dictionary

Bodor Máté's avatar
v0.08    
Bodor Máté committed
341
342
+++

Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
Kulcs érték pár

A kulcs egyedi, érték bármi lehet

```python
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}
```

```python
print ("dict['Name']: ", dict['Name'])
dict['Age'] = 8
del dict['Name']
```

---

Bodor Máté's avatar
v0.08    
Bodor Máté committed
359
360
361
### Függvények
---

Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
### Alap beépített fgv-ek

int

hex

oct

str

len

list

range

Bodor Máté's avatar
v0.01    
Bodor Máté committed
378
---
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
379
### Ciklusok
Bodor Máté's avatar
v0.01    
Bodor Máté committed
380
---
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
381
#### While
Bodor Máté's avatar
v0.08    
Bodor Máté committed
382
+++
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
383
384
385
386
387
388
389
390
391
392
393
394
395
396
```python
count = 0
while (count < 9):
   print ('The count is:', count)
   count = count + 1
```

```python
>>> range(5)
range(0, 5)
>>> list(range(5))
[0, 1, 2, 3, 4]
```

Bodor Máté's avatar
v0.01    
Bodor Máté committed
397
---
398

Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
399
400
#### For

Bodor Máté's avatar
v0.08    
Bodor Máté committed
401
+++
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
```python
for var in range(5):
   print (var)
```

```python
for letter in 'Python':     # traversal of a string sequence
   print ('Current Letter :', letter)
print()
fruits = ['banana', 'apple',  'mango']

for fruit in fruits:        # traversal of List sequence
   print ('Current fruit :', fruit)
```

Bodor Máté's avatar
v0.01    
Bodor Máté committed
417
418
---

Bodor Máté's avatar
v0.08    
Bodor Máté committed
419
### Elágazások
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
420

Bodor Máté's avatar
v0.08    
Bodor Máté committed
421
+++
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
```python
if expression1:
   statement(s)
elif expression2:
   statement(s)
elif expression3:
   statement(s)
else:
   statement(s)
```

---

### Osztályok

Bodor Máté's avatar
v0.08    
Bodor Máté committed
437
+++
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
```python
class Employee:
   'Common base class for all employees'
   empCount = 0

   def __init__(self, name, salary):
      self.name = name
      self.salary = salary
      Employee.empCount += 1
   
   def displayCount(self):
     print ("Total Employee %d" % Employee.empCount)

   def displayEmployee(self):
      print ("Name : ", self.name,  ", Salary: ", self.salary)
```

Bodor Máté's avatar
v0.01    
Bodor Máté committed
455
---
Bodnár Zsombor's avatar
WIP    
Bodnár Zsombor committed
456

Bodor Máté's avatar
v0.08    
Bodor Máté committed
457
458
459
460
### Getter, Setter

+++
a