際際滷

際際滷Share a Scribd company logo
Python 101
 Kiattisak Anoochitarom
     NSC Camp #5
Whos Invent ?



    Guido van Rossum
    Software Engineer at Google inc.
Programming Structure

  Indentation
  strong & dynamic type
  short and readable code
  interpreter style
PEP-8

犢犖犖朽権犖 Python 犢犖犖∇犖÷犖犢犖迦 PEP-8 犖犖劇賢犖о犖迦犖犢犖 犖犖迦
 - 犖犢犖迦犖犢犖迦権 (Readability)
 - 犖犖ム検犖犖ム厳犖 (Consistency)

Guido 犖犖犖犖о犖 Programmer 犖犢犖о犢犖犖犢犖÷険犖犖犖萎賢犢犖迦 Code 犖÷顕犖犖犖о犖
犢犖犖朽権犖 犖犖園犖犖園犖犖犢犖迦犖萎犖犖朽権犖犖犖о牽犢犖犖朽権犖犢犖犢犖犢犖迦犖犢犖迦権
PEP-8 Overview [1]

 4 white spaces or 1 tab for indentation
 犖犖∇犖迦犖犢犢犖犢犖ム鍵犖犖犖犖犖園犢犖犖巌 79 犖犖園硯犖犖園犖犖
 犖犖園犖犖犢犖о犖犢犖迦犢 犖犖犖犢犖犖犢犖犖犖÷犢犖о権犖犖迦牽犢犖о犖犖犖犖犖犖園
PEP-8 Overview [2]
import library 1 犖犖園硯犖犢犖 1 犖犖犖犖犖園
import 犖犖朽犖犢犖迦犖犖犖犖犖犢犖犖ム犢犖犖÷賢
import cv
import bs4                                          Yes:
from subprocess import Popen, PIPE                    x=1
                                                      y=2
                  Yes: spam(ham[1], {eggs: 2})        long_variable = 3
                  No: spam( ham[ 1 ], { eggs: 2})   No:
                                                      x            =1
                  Yes: dict[key] = list[index]      y             =2
                  No: dict [key] = list [index]     long_variable = 3

    犖犖∇犖迦犖犢 whitespace 犖犖犢犢犖迦犖犖犖劇犖 (1 犖犖犖犖犖園犢犖÷犖犖о牽犢犖犖巌 79 犖犖園硯犖犖園犖犖)
Data Type

    String                 str = message
   Integer                   number = 20
Floating Point                pi = 3.14159
   Boolean              isParse = True, False
    None                          None
     List                    list = [1, 2, 3]
  Dictionary        me = {name: Bas, No: 1}
Class instance              a = MyClass()
Operator
Basic Operator
 +, -, *, /, %, **, &, |       warning!
                               - int/int == int
                               - int**(-int) == 鍖oat
Comparison Operator
                               - int/鍖oat == 鍖oat
>, >=, <, <=, ==, !=, is       - string + string == concat string
                               - string * int == multiple string
                               - list + list = list



shortly
i = i + 1 == i += 1
Logical Operator
犢犖 Python 犢犖犖迦犖萎犖犢 & 犢犖ム鍵 | (Pipe) 犢犖犖劇犖犖犢犖 and, or Operation
犢犖犢犢犖 Python 犖犢犖÷元 Operator 犖犖巌犖犖犢犖ム鍵犖犖巌権犖÷犖犢犖犖園犖犖園犖犖犖劇賢


                        and , or

                                       shortly logical operation
                                              x &= (a == b)
                                                   ==
                                           x = x and (a == b)
Control Statement (if)
                                       If
                          condition statement
         犢犖犖劇犖犖犢犖犖犖犖 if 犢犖÷犖犢犖犖犢犖犢犖о犢犖ム犖 犢犖о犖犢犖犢犖о犖迦犖犖劇犖犖犢犖犖犖萎検犖朽見犖ム顕犖∇犖犖犖犖園



number = int(input(Enter Number: ))       number = int(input(Enter Number: ))
if number > 0:                              if number % 2 == 0 or number % 4 == 0
   print Number is Positive                  or number % 5 == 0:
elif number < 0:                                  print Number divided by 2, 4, 5
   print Number is Negative
else:
   print Number is Zero
Control Statement (for)
  For (foreach)
    loop statement
                          list = [7, 8, 9, 10]
for x in xrange(10):      for index, value in enumerate(list):
  print x                      print index, value

for x in xrange(3, 20):
  print x
                           x=0                Endless Loop
name = [a, b, c]     while (x <= 10):   while True:
for x in name               print x             if condition:
  print x                   x += 1                 break;
Play with List, Dictionary



       string method and slice
     list and list method demo
           dictionary demo
     mixed type list, dictionary
Function
Function Syntax:
   def function_name(set of parameter):
     statement ..
     statement ..

def 鍖bonacci(n):
  鍖bo = 0;
  for k in xrange(0, int(math.鍖oor((n - 1) / 2)) + 1):
     鍖bo += math.factorial(n - k - 1) / 
          (math.factorial(k) * math.factorial(n - k - 1 - k))
  return 鍖bo


Muti-Return Data
Python OOP
- Class = 犢犖÷犖犖巌検犖犢犖犖犖
- Object, Instance = 犖犖犖
- Python Class 犖犢犢犖犢犖犢犖犖朽権犖о犖園
- Python Class 犖犖 subclass 犖犖迦 Class object 犢犖犖÷賢


                 Demo:
                 - create class
                 - constructor and destructor
                 - create class instance
                 - using class
Read and Write File
open(鍖lename, mode)
             r = read # 犢犖犖巌犢犖犖ム犢犖犖劇犖犖犢犖迦
             w = write # 犢犖犖巌犢犖犖ム犢犖犖劇犖犢犖犖朽権犖犖犖園
             a = append # 犢犖犖巌犢犖犖ム犢犖犖劇犖犢犖犖朽権犖犖犢犖

鍖le = open(鍖lename.txt, r)
鍖le.read() # 犖犢犖迦犢犖犖ム犖犖園犖犖犖÷犢犖犢犖 String
鍖le.readline() # 犖犢犖迦犢犖犖ム犖犖朽献犖萎犖犖犖犖園
鍖le.readlines() # 犖犢犖迦犢犖犖ム犖犖伍犖犖犖犖犖園犖犖犖犖÷顕犢犖犢犖 List of String

鍖le.write(string) # 犢犖犖朽権犖 String 犖犖園犖犖犖÷犖ム犢犖犖ム
鍖le.writelines([list of string]) # 犢犖犖朽権犖 List of String 犖ム犢犖犖ム
1-liner
犖犖犖犖犖園犢犖犖朽権犖о犢犢犖犖朽権犖о犖犢




                   - sum
                   - list comprehensive
                   - shorten if
Tools

Editor
 - Vim
 - Sublime              Interactive Shell
                         - python shell
                         - ipython
IDE                      - bpython
 - Eclipse + PyDev       - IDLE
 - Eric IDE
 - Komodo
Libraries



Libraries 犖犖犖 Python 犖÷元犢犖∇賢犖萎検犖迦
犖犖迦犖犢犖犖迦 PyPI - http://pypi.python.org/pypi
Its Application

Digital Image Processing (Python Imaging Library)
           Computer Vision (OpenCV)
            Web Framework (Django)
          Web Server (Gunicorn, Tornado)
  Web Client (Beautiful Soup, urllib3, html5lib)
       Content Management System (Plone)
       Natural Language Processing (NLTK)

More Related Content

What's hot (20)

犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犖犖園犖犖犖劇犖犖犖迦
犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犖犖園犖犖犖劇犖犖犖迦犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犖犖園犖犖犖劇犖犖犖迦
犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犖犖園犖犖犖劇犖犖犖迦
Nookky Anapat
犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖
犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖
犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖
Sarocha Makranit
犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖
犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖
犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖
Aeew Autaporn
犖犖迦県犖 C#
犖犖迦県犖 C#犖犖迦県犖 C#
犖犖迦県犖 C#
ictyangtalad
PHP Tutorial (introduction)
PHP Tutorial (introduction)PHP Tutorial (introduction)
PHP Tutorial (introduction)
Tinnakorn Puttha
Java Programming: 犢犖犖犖犖犖犢犖迦犖犖о犖犖伍検
Java Programming: 犢犖犖犖犖犖犢犖迦犖犖о犖犖伍検Java Programming: 犢犖犖犖犖犖犢犖迦犖犖о犖犖伍検
Java Programming: 犢犖犖犖犖犖犢犖迦犖犖о犖犖伍検
Thanachart Numnonda
Java Programming [12/12] : Thread
Java Programming [12/12] : ThreadJava Programming [12/12] : Thread
Java Programming [12/12] : Thread
IMC Institute
犢犖犖犢犖犖犖÷権犢犖犖∇犖ム鍵犖犖園犖犢犖犖園
犢犖犖犢犖犖犖÷権犢犖犖∇犖ム鍵犖犖園犖犢犖犖園犢犖犖犢犖犖犖÷権犢犖犖∇犖ム鍵犖犖園犖犢犖犖園
犢犖犖犢犖犖犖÷権犢犖犖∇犖ム鍵犖犖園犖犢犖犖園
犖犖犖萎犖迦犖 犢犖犖朽権犖÷見犖犖
犖犖о顕犖÷牽犖項犢犖犖劇犖犖犖犢犖犖犖迦県犖迦犖迦硯犖
犖犖о顕犖÷牽犖項犢犖犖劇犖犖犖犢犖犖犖迦県犖迦犖迦硯犖犖犖о顕犖÷牽犖項犢犖犖劇犖犖犖犢犖犖犖迦県犖迦犖迦硯犖
犖犖о顕犖÷牽犖項犢犖犖劇犖犖犖犢犖犖犖迦県犖迦犖迦硯犖
Thanachart Numnonda
Java Programming: 犖犖萎犖犖∇犢犖ム鍵犖犖犖ム犖ム犖犖犖園犖
Java Programming: 犖犖萎犖犖∇犢犖ム鍵犖犖犖ム犖ム犖犖犖園犖Java Programming: 犖犖萎犖犖∇犢犖ム鍵犖犖犖ム犖ム犖犖犖園犖
Java Programming: 犖犖萎犖犖∇犢犖ム鍵犖犖犖ム犖ム犖犖犖園犖
Thanachart Numnonda
犖犖迦牽犢犖犖朽権犖犢犖犖犢犖犖犖÷犖犖劇犖犖犖迦犖犖迦犖朽 6.
犖犖迦牽犢犖犖朽権犖犢犖犖犢犖犖犖÷犖犖劇犖犖犖迦犖犖迦犖朽 6.犖犖迦牽犢犖犖朽権犖犢犖犖犢犖犖犖÷犖犖劇犖犖犖迦犖犖迦犖朽 6.
犖犖迦牽犢犖犖朽権犖犢犖犖犢犖犖犖÷犖犖劇犖犖犖迦犖犖迦犖朽 6.
Ploy StopDark
犢犖犖犢犖犖犖÷権犢犖犖∇犖ム鍵犖犖園犖犢犖犖園 犖÷顕犖犖犖犖迦 6
犢犖犖犢犖犖犖÷権犢犖犖∇犖ム鍵犖犖園犖犢犖犖園 犖÷顕犖犖犖犖迦 6犢犖犖犢犖犖犖÷権犢犖犖∇犖ム鍵犖犖園犖犢犖犖園 犖÷顕犖犖犖犖迦 6
犢犖犖犢犖犖犖÷権犢犖犖∇犖ム鍵犖犖園犖犢犖犖園 犖÷顕犖犖犖犖迦 6
Ploy StopDark
Java Programming: 犖犖迦牽犖犖園犖犖迦牽犖犖園犖犢犖犖犖巌犖犖ム顕犖
Java Programming: 犖犖迦牽犖犖園犖犖迦牽犖犖園犖犢犖犖犖巌犖犖ム顕犖Java Programming: 犖犖迦牽犖犖園犖犖迦牽犖犖園犖犢犖犖犖巌犖犖ム顕犖
Java Programming: 犖犖迦牽犖犖園犖犖迦牽犖犖園犖犢犖犖犖巌犖犖ム顕犖
Thanachart Numnonda
Java Programming: 犖犖迦牽犖犖犢犖迦犖犢犖о犖犢犖犖犖犖萎肩犖迦姑┯犖犖迦犖巌犖犖園犖犖項犢犖犢 (Java GUI)
Java Programming: 犖犖迦牽犖犖犢犖迦犖犢犖о犖犢犖犖犖犖萎肩犖迦姑┯犖犖迦犖巌犖犖園犖犖項犢犖犢 (Java GUI)Java Programming: 犖犖迦牽犖犖犢犖迦犖犢犖о犖犢犖犖犖犖萎肩犖迦姑┯犖犖迦犖巌犖犖園犖犖項犢犖犢 (Java GUI)
Java Programming: 犖犖迦牽犖犖犢犖迦犖犢犖о犖犢犖犖犖犖萎肩犖迦姑┯犖犖迦犖巌犖犖園犖犖項犢犖犢 (Java GUI)
Thanachart Numnonda
C lang
C langC lang
C lang
Nattawut Pornonsung
Java Programming: 犖犖ム険犖犖犖迦牽犢犖犖巌犖犢犖犖犢犖犖犖犢
Java Programming: 犖犖ム険犖犖犖迦牽犢犖犖巌犖犢犖犖犢犖犖犖犢Java Programming: 犖犖ム険犖犖犖迦牽犢犖犖巌犖犢犖犖犢犖犖犖犢
Java Programming: 犖犖ム険犖犖犖迦牽犢犖犖巌犖犢犖犖犢犖犖犖犢
Thanachart Numnonda
犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犖犖園犖犖犖劇犖犖犖迦
犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犖犖園犖犖犖劇犖犖犖迦犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犖犖園犖犖犖劇犖犖犖迦
犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犖犖園犖犖犖劇犖犖犖迦
Nookky Anapat
犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖
犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖
犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖
Sarocha Makranit
犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖
犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖
犖犖劇犖犖犖迦姑┯犖迦県犖迦犖迦硯犖
Aeew Autaporn
犖犖迦県犖 C#
犖犖迦県犖 C#犖犖迦県犖 C#
犖犖迦県犖 C#
ictyangtalad
PHP Tutorial (introduction)
PHP Tutorial (introduction)PHP Tutorial (introduction)
PHP Tutorial (introduction)
Tinnakorn Puttha
Java Programming: 犢犖犖犖犖犖犢犖迦犖犖о犖犖伍検
Java Programming: 犢犖犖犖犖犖犢犖迦犖犖о犖犖伍検Java Programming: 犢犖犖犖犖犖犢犖迦犖犖о犖犖伍検
Java Programming: 犢犖犖犖犖犖犢犖迦犖犖о犖犖伍検
Thanachart Numnonda
Java Programming [12/12] : Thread
Java Programming [12/12] : ThreadJava Programming [12/12] : Thread
Java Programming [12/12] : Thread
IMC Institute
犖犖о顕犖÷牽犖項犢犖犖劇犖犖犖犢犖犖犖迦県犖迦犖迦硯犖
犖犖о顕犖÷牽犖項犢犖犖劇犖犖犖犢犖犖犖迦県犖迦犖迦硯犖犖犖о顕犖÷牽犖項犢犖犖劇犖犖犖犢犖犖犖迦県犖迦犖迦硯犖
犖犖о顕犖÷牽犖項犢犖犖劇犖犖犖犢犖犖犖迦県犖迦犖迦硯犖
Thanachart Numnonda
Java Programming: 犖犖萎犖犖∇犢犖ム鍵犖犖犖ム犖ム犖犖犖園犖
Java Programming: 犖犖萎犖犖∇犢犖ム鍵犖犖犖ム犖ム犖犖犖園犖Java Programming: 犖犖萎犖犖∇犢犖ム鍵犖犖犖ム犖ム犖犖犖園犖
Java Programming: 犖犖萎犖犖∇犢犖ム鍵犖犖犖ム犖ム犖犖犖園犖
Thanachart Numnonda
犖犖迦牽犢犖犖朽権犖犢犖犖犢犖犖犖÷犖犖劇犖犖犖迦犖犖迦犖朽 6.
犖犖迦牽犢犖犖朽権犖犢犖犖犢犖犖犖÷犖犖劇犖犖犖迦犖犖迦犖朽 6.犖犖迦牽犢犖犖朽権犖犢犖犖犢犖犖犖÷犖犖劇犖犖犖迦犖犖迦犖朽 6.
犖犖迦牽犢犖犖朽権犖犢犖犖犢犖犖犖÷犖犖劇犖犖犖迦犖犖迦犖朽 6.
Ploy StopDark
犢犖犖犢犖犖犖÷権犢犖犖∇犖ム鍵犖犖園犖犢犖犖園 犖÷顕犖犖犖犖迦 6
犢犖犖犢犖犖犖÷権犢犖犖∇犖ム鍵犖犖園犖犢犖犖園 犖÷顕犖犖犖犖迦 6犢犖犖犢犖犖犖÷権犢犖犖∇犖ム鍵犖犖園犖犢犖犖園 犖÷顕犖犖犖犖迦 6
犢犖犖犢犖犖犖÷権犢犖犖∇犖ム鍵犖犖園犖犢犖犖園 犖÷顕犖犖犖犖迦 6
Ploy StopDark
Java Programming: 犖犖迦牽犖犖園犖犖迦牽犖犖園犖犢犖犖犖巌犖犖ム顕犖
Java Programming: 犖犖迦牽犖犖園犖犖迦牽犖犖園犖犢犖犖犖巌犖犖ム顕犖Java Programming: 犖犖迦牽犖犖園犖犖迦牽犖犖園犖犢犖犖犖巌犖犖ム顕犖
Java Programming: 犖犖迦牽犖犖園犖犖迦牽犖犖園犖犢犖犖犖巌犖犖ム顕犖
Thanachart Numnonda
Java Programming: 犖犖迦牽犖犖犢犖迦犖犢犖о犖犢犖犖犖犖萎肩犖迦姑┯犖犖迦犖巌犖犖園犖犖項犢犖犢 (Java GUI)
Java Programming: 犖犖迦牽犖犖犢犖迦犖犢犖о犖犢犖犖犖犖萎肩犖迦姑┯犖犖迦犖巌犖犖園犖犖項犢犖犢 (Java GUI)Java Programming: 犖犖迦牽犖犖犢犖迦犖犢犖о犖犢犖犖犖犖萎肩犖迦姑┯犖犖迦犖巌犖犖園犖犖項犢犖犢 (Java GUI)
Java Programming: 犖犖迦牽犖犖犢犖迦犖犢犖о犖犢犖犖犖犖萎肩犖迦姑┯犖犖迦犖巌犖犖園犖犖項犢犖犢 (Java GUI)
Thanachart Numnonda
Java Programming: 犖犖ム険犖犖犖迦牽犢犖犖巌犖犢犖犖犢犖犖犖犢
Java Programming: 犖犖ム険犖犖犖迦牽犢犖犖巌犖犢犖犖犢犖犖犖犢Java Programming: 犖犖ム険犖犖犖迦牽犢犖犖巌犖犢犖犖犢犖犖犖犢
Java Programming: 犖犖ム険犖犖犖迦牽犢犖犖巌犖犢犖犖犢犖犖犖犢
Thanachart Numnonda

Viewers also liked (20)

DEVNET-1114 Automated Management Using SDN/NFV
DEVNET-1114	Automated Management Using SDN/NFVDEVNET-1114	Automated Management Using SDN/NFV
DEVNET-1114 Automated Management Using SDN/NFV
Cisco DevNet
DEVNET-2002 Coding 201: Coding Skills 201: Going Further with REST and Python...
DEVNET-2002	Coding 201: Coding Skills 201: Going Further with REST and Python...DEVNET-2002	Coding 201: Coding Skills 201: Going Further with REST and Python...
DEVNET-2002 Coding 201: Coding Skills 201: Going Further with REST and Python...
Cisco DevNet
Manufacturingofmicroprocessor 120813121945-phpapp02
Manufacturingofmicroprocessor 120813121945-phpapp02Manufacturingofmicroprocessor 120813121945-phpapp02
Manufacturingofmicroprocessor 120813121945-phpapp02
Waqar Mughal
O lectie de patriotism local
O lectie de patriotism localO lectie de patriotism local
O lectie de patriotism local
lazardiana
Git slide
Git slideGit slide
Git slide
Kiattisak Anoochitarom
Shasta county mou 2013
Shasta county mou 2013Shasta county mou 2013
Shasta county mou 2013
CUHW Local 4034
Proposta di deliberazione prot. n. 259 del 2012 (2)
Proposta di deliberazione prot. n. 259 del 2012 (2)Proposta di deliberazione prot. n. 259 del 2012 (2)
Proposta di deliberazione prot. n. 259 del 2012 (2)
Fballer77
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
KHNOG
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple Steps
Tessa Mero
Simulation training in medicine and technology management
Simulation training in medicine and technology managementSimulation training in medicine and technology management
Simulation training in medicine and technology management
MCH-org-ua
Coding 102 REST API Basics Using Spark
Coding 102 REST API Basics Using SparkCoding 102 REST API Basics Using Spark
Coding 102 REST API Basics Using Spark
Cisco DevNet
Cisco CSR1000V, VMware, and RESTful APIs
Cisco CSR1000V, VMware, and RESTful APIsCisco CSR1000V, VMware, and RESTful APIs
Cisco CSR1000V, VMware, and RESTful APIs
Private
Cisco application infrastracture controller (apic) billyjones
Cisco application infrastracture controller (apic) billyjonesCisco application infrastracture controller (apic) billyjones
Cisco application infrastracture controller (apic) billyjones
Billy jones Monarquia
DEVNET-1126 APIC-EM API
DEVNET-1126	APIC-EM APIDEVNET-1126	APIC-EM API
DEVNET-1126 APIC-EM API
Cisco DevNet
Bidirectional Forwarding Detection (BFD)
Bidirectional Forwarding Detection (BFD) Bidirectional Forwarding Detection (BFD)
Bidirectional Forwarding Detection (BFD)
KHNOG
Network Mapper (NMAP)
Network Mapper (NMAP)Network Mapper (NMAP)
Network Mapper (NMAP)
KHNOG
WorkShop SDN / ACI - Jeudi 12 F辿vrier 2015WorkShop SDN / ACI - Jeudi 12 F辿vrier 2015
WorkShop SDN / ACI - Jeudi 12 F辿vrier 2015
Dig-IT
Cach giai bai tap dai tu quan he
Cach giai bai tap dai tu quan heCach giai bai tap dai tu quan he
Cach giai bai tap dai tu quan he
Ng畛c Long
Policy Based Routing (PBR)
Policy Based Routing (PBR)Policy Based Routing (PBR)
Policy Based Routing (PBR)
KHNOG
DEVNET-1114 Automated Management Using SDN/NFV
DEVNET-1114	Automated Management Using SDN/NFVDEVNET-1114	Automated Management Using SDN/NFV
DEVNET-1114 Automated Management Using SDN/NFV
Cisco DevNet
DEVNET-2002 Coding 201: Coding Skills 201: Going Further with REST and Python...
DEVNET-2002	Coding 201: Coding Skills 201: Going Further with REST and Python...DEVNET-2002	Coding 201: Coding Skills 201: Going Further with REST and Python...
DEVNET-2002 Coding 201: Coding Skills 201: Going Further with REST and Python...
Cisco DevNet
Manufacturingofmicroprocessor 120813121945-phpapp02
Manufacturingofmicroprocessor 120813121945-phpapp02Manufacturingofmicroprocessor 120813121945-phpapp02
Manufacturingofmicroprocessor 120813121945-phpapp02
Waqar Mughal
O lectie de patriotism local
O lectie de patriotism localO lectie de patriotism local
O lectie de patriotism local
lazardiana
Shasta county mou 2013
Shasta county mou 2013Shasta county mou 2013
Shasta county mou 2013
CUHW Local 4034
Proposta di deliberazione prot. n. 259 del 2012 (2)
Proposta di deliberazione prot. n. 259 del 2012 (2)Proposta di deliberazione prot. n. 259 del 2012 (2)
Proposta di deliberazione prot. n. 259 del 2012 (2)
Fballer77
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
KHNOG
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple Steps
Tessa Mero
Simulation training in medicine and technology management
Simulation training in medicine and technology managementSimulation training in medicine and technology management
Simulation training in medicine and technology management
MCH-org-ua
Coding 102 REST API Basics Using Spark
Coding 102 REST API Basics Using SparkCoding 102 REST API Basics Using Spark
Coding 102 REST API Basics Using Spark
Cisco DevNet
Cisco CSR1000V, VMware, and RESTful APIs
Cisco CSR1000V, VMware, and RESTful APIsCisco CSR1000V, VMware, and RESTful APIs
Cisco CSR1000V, VMware, and RESTful APIs
Private
Cisco application infrastracture controller (apic) billyjones
Cisco application infrastracture controller (apic) billyjonesCisco application infrastracture controller (apic) billyjones
Cisco application infrastracture controller (apic) billyjones
Billy jones Monarquia
DEVNET-1126 APIC-EM API
DEVNET-1126	APIC-EM APIDEVNET-1126	APIC-EM API
DEVNET-1126 APIC-EM API
Cisco DevNet
Bidirectional Forwarding Detection (BFD)
Bidirectional Forwarding Detection (BFD) Bidirectional Forwarding Detection (BFD)
Bidirectional Forwarding Detection (BFD)
KHNOG
Network Mapper (NMAP)
Network Mapper (NMAP)Network Mapper (NMAP)
Network Mapper (NMAP)
KHNOG
WorkShop SDN / ACI - Jeudi 12 F辿vrier 2015WorkShop SDN / ACI - Jeudi 12 F辿vrier 2015
WorkShop SDN / ACI - Jeudi 12 F辿vrier 2015
Dig-IT
Cach giai bai tap dai tu quan he
Cach giai bai tap dai tu quan heCach giai bai tap dai tu quan he
Cach giai bai tap dai tu quan he
Ng畛c Long
Policy Based Routing (PBR)
Policy Based Routing (PBR)Policy Based Routing (PBR)
Policy Based Routing (PBR)
KHNOG

Similar to Python101 (20)

RTAF_Basic_Python_2022_Cyber_Operation_Contest.pptx
RTAF_Basic_Python_2022_Cyber_Operation_Contest.pptxRTAF_Basic_Python_2022_Cyber_Operation_Contest.pptx
RTAF_Basic_Python_2022_Cyber_Operation_Contest.pptx
nkrafacyberclub
犢犖犖犖о顕犖÷牽犖項犖犖朽 1 犖犖о顕犖÷牽犖項犖犖劇犖犖犖迦犢犖犖犢犖犖犖÷犖迦県犖迦犖
犢犖犖犖о顕犖÷牽犖項犖犖朽 1 犖犖о顕犖÷牽犖項犖犖劇犖犖犖迦犢犖犖犢犖犖犖÷犖迦県犖迦犖犢犖犖犖о顕犖÷牽犖項犖犖朽 1 犖犖о顕犖÷牽犖項犖犖劇犖犖犖迦犢犖犖犢犖犖犖÷犖迦県犖迦犖
犢犖犖犖о顕犖÷牽犖項犖犖朽 1 犖犖о顕犖÷牽犖項犖犖劇犖犖犖迦犢犖犖犢犖犖犖÷犖迦県犖迦犖
Nattapon
犖犖犖犖朽 7
犖犖犖犖朽 7犖犖犖犖朽 7
犖犖犖犖朽 7
Wittaya Kaewchat
Computer Programming 2.1
Computer Programming 2.1Computer Programming 2.1
Computer Programming 2.1
Saranyu Srisrontong
Computer Programming 2.2
Computer Programming 2.2Computer Programming 2.2
Computer Programming 2.2
Saranyu Srisrontong
犖犖犖犖朽 5 犖犢犖犖÷弦犖ム犖犖巌犖犖迦牽犢犢犖犖∇犢犖ム鍵犖犖犖犖巌 6.1
犖犖犖犖朽  5 犖犢犖犖÷弦犖ム犖犖巌犖犖迦牽犢犢犖犖∇犢犖ム鍵犖犖犖犖巌 6.1犖犖犖犖朽  5 犖犢犖犖÷弦犖ム犖犖巌犖犖迦牽犢犢犖犖∇犢犖ム鍵犖犖犖犖巌 6.1
犖犖犖犖朽 5 犖犢犖犖÷弦犖ム犖犖巌犖犖迦牽犢犢犖犖∇犢犖ム鍵犖犖犖犖巌 6.1
Little Tukta Lita
犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犢犖犖犖÷元犖犖迦犢仰犖ム厳犖犖.
犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犢犖犖犖÷元犖犖迦犢仰犖ム厳犖犖.犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犢犖犖犖÷元犖犖迦犢仰犖ム厳犖犖.
犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犢犖犖犖÷元犖犖迦犢仰犖ム厳犖犖.
Mink Kamolwan
Midterm
MidtermMidterm
Midterm
Sirirat Mahawan
犖犖迦牽犖犖犢犖迦犢犖犖犖犖犖犖犖迦検
 犖犖迦牽犖犖犢犖迦犢犖犖犖犖犖犖犖迦検 犖犖迦牽犖犖犢犖迦犢犖犖犖犖犖犖犖迦検
犖犖迦牽犖犖犢犖迦犢犖犖犖犖犖犖犖迦検
kruthanyaporn
Java-Answer Chapter 05-06
Java-Answer Chapter 05-06Java-Answer Chapter 05-06
Java-Answer Chapter 05-06
Wongyos Keardsri
RTAF_Basic_Python_2022_Cyber_Operation_Contest.pptx
RTAF_Basic_Python_2022_Cyber_Operation_Contest.pptxRTAF_Basic_Python_2022_Cyber_Operation_Contest.pptx
RTAF_Basic_Python_2022_Cyber_Operation_Contest.pptx
nkrafacyberclub
犢犖犖犖о顕犖÷牽犖項犖犖朽 1 犖犖о顕犖÷牽犖項犖犖劇犖犖犖迦犢犖犖犢犖犖犖÷犖迦県犖迦犖
犢犖犖犖о顕犖÷牽犖項犖犖朽 1 犖犖о顕犖÷牽犖項犖犖劇犖犖犖迦犢犖犖犢犖犖犖÷犖迦県犖迦犖犢犖犖犖о顕犖÷牽犖項犖犖朽 1 犖犖о顕犖÷牽犖項犖犖劇犖犖犖迦犢犖犖犢犖犖犖÷犖迦県犖迦犖
犢犖犖犖о顕犖÷牽犖項犖犖朽 1 犖犖о顕犖÷牽犖項犖犖劇犖犖犖迦犢犖犖犢犖犖犖÷犖迦県犖迦犖
Nattapon
犖犖犖犖朽 5 犖犢犖犖÷弦犖ム犖犖巌犖犖迦牽犢犢犖犖∇犢犖ム鍵犖犖犖犖巌 6.1
犖犖犖犖朽  5 犖犢犖犖÷弦犖ム犖犖巌犖犖迦牽犢犢犖犖∇犢犖ム鍵犖犖犖犖巌 6.1犖犖犖犖朽  5 犖犢犖犖÷弦犖ム犖犖巌犖犖迦牽犢犢犖犖∇犢犖ム鍵犖犖犖犖巌 6.1
犖犖犖犖朽 5 犖犢犖犖÷弦犖ム犖犖巌犖犖迦牽犢犢犖犖∇犢犖ム鍵犖犖犖犖巌 6.1
Little Tukta Lita
犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犢犖犖犖÷元犖犖迦犢仰犖ム厳犖犖.
犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犢犖犖犖÷元犖犖迦犢仰犖ム厳犖犖.犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犢犖犖犖÷元犖犖迦犢仰犖ム厳犖犖.
犖犖迦牽犢犖犖朽権犖犖犖橿肩犖園犖犖犖о犖犖伍検犢犖犖犖÷元犖犖迦犢仰犖ム厳犖犖.
Mink Kamolwan
犖犖迦牽犖犖犢犖迦犢犖犖犖犖犖犖犖迦検
 犖犖迦牽犖犖犢犖迦犢犖犖犖犖犖犖犖迦検 犖犖迦牽犖犖犢犖迦犢犖犖犖犖犖犖犖迦検
犖犖迦牽犖犖犢犖迦犢犖犖犖犖犖犖犖迦検
kruthanyaporn
Java-Answer Chapter 05-06
Java-Answer Chapter 05-06Java-Answer Chapter 05-06
Java-Answer Chapter 05-06
Wongyos Keardsri

Python101

  • 1. Python 101 Kiattisak Anoochitarom NSC Camp #5
  • 2. Whos Invent ? Guido van Rossum Software Engineer at Google inc.
  • 3. Programming Structure Indentation strong & dynamic type short and readable code interpreter style
  • 4. PEP-8 犢犖犖朽権犖 Python 犢犖犖∇犖÷犖犢犖迦 PEP-8 犖犖劇賢犖о犖迦犖犢犖 犖犖迦 - 犖犢犖迦犖犢犖迦権 (Readability) - 犖犖ム検犖犖ム厳犖 (Consistency) Guido 犖犖犖犖о犖 Programmer 犖犢犖о犢犖犖犢犖÷険犖犖犖萎賢犢犖迦 Code 犖÷顕犖犖犖о犖 犢犖犖朽権犖 犖犖園犖犖園犖犖犢犖迦犖萎犖犖朽権犖犖犖о牽犢犖犖朽権犖犢犖犢犖犢犖迦犖犢犖迦権
  • 5. PEP-8 Overview [1] 4 white spaces or 1 tab for indentation 犖犖∇犖迦犖犢犢犖犢犖ム鍵犖犖犖犖犖園犢犖犖巌 79 犖犖園硯犖犖園犖犖 犖犖園犖犖犢犖о犖犢犖迦犢 犖犖犖犢犖犖犢犖犖犖÷犢犖о権犖犖迦牽犢犖о犖犖犖犖犖犖園
  • 6. PEP-8 Overview [2] import library 1 犖犖園硯犖犢犖 1 犖犖犖犖犖園 import 犖犖朽犖犢犖迦犖犖犖犖犖犢犖犖ム犢犖犖÷賢 import cv import bs4 Yes: from subprocess import Popen, PIPE x=1 y=2 Yes: spam(ham[1], {eggs: 2}) long_variable = 3 No: spam( ham[ 1 ], { eggs: 2}) No: x =1 Yes: dict[key] = list[index] y =2 No: dict [key] = list [index] long_variable = 3 犖犖∇犖迦犖犢 whitespace 犖犖犢犢犖迦犖犖犖劇犖 (1 犖犖犖犖犖園犢犖÷犖犖о牽犢犖犖巌 79 犖犖園硯犖犖園犖犖)
  • 7. Data Type String str = message Integer number = 20 Floating Point pi = 3.14159 Boolean isParse = True, False None None List list = [1, 2, 3] Dictionary me = {name: Bas, No: 1} Class instance a = MyClass()
  • 8. Operator Basic Operator +, -, *, /, %, **, &, | warning! - int/int == int - int**(-int) == 鍖oat Comparison Operator - int/鍖oat == 鍖oat >, >=, <, <=, ==, !=, is - string + string == concat string - string * int == multiple string - list + list = list shortly i = i + 1 == i += 1
  • 9. Logical Operator 犢犖 Python 犢犖犖迦犖萎犖犢 & 犢犖ム鍵 | (Pipe) 犢犖犖劇犖犖犢犖 and, or Operation 犢犖犢犢犖 Python 犖犢犖÷元 Operator 犖犖巌犖犖犢犖ム鍵犖犖巌権犖÷犖犢犖犖園犖犖園犖犖犖劇賢 and , or shortly logical operation x &= (a == b) == x = x and (a == b)
  • 10. Control Statement (if) If condition statement 犢犖犖劇犖犖犢犖犖犖犖 if 犢犖÷犖犢犖犖犢犖犢犖о犢犖ム犖 犢犖о犖犢犖犢犖о犖迦犖犖劇犖犖犢犖犖犖萎検犖朽見犖ム顕犖∇犖犖犖犖園 number = int(input(Enter Number: )) number = int(input(Enter Number: )) if number > 0: if number % 2 == 0 or number % 4 == 0 print Number is Positive or number % 5 == 0: elif number < 0: print Number divided by 2, 4, 5 print Number is Negative else: print Number is Zero
  • 11. Control Statement (for) For (foreach) loop statement list = [7, 8, 9, 10] for x in xrange(10): for index, value in enumerate(list): print x print index, value for x in xrange(3, 20): print x x=0 Endless Loop name = [a, b, c] while (x <= 10): while True: for x in name print x if condition: print x x += 1 break;
  • 12. Play with List, Dictionary string method and slice list and list method demo dictionary demo mixed type list, dictionary
  • 13. Function Function Syntax: def function_name(set of parameter): statement .. statement .. def 鍖bonacci(n): 鍖bo = 0; for k in xrange(0, int(math.鍖oor((n - 1) / 2)) + 1): 鍖bo += math.factorial(n - k - 1) / (math.factorial(k) * math.factorial(n - k - 1 - k)) return 鍖bo Muti-Return Data
  • 14. Python OOP - Class = 犢犖÷犖犖巌検犖犢犖犖犖 - Object, Instance = 犖犖犖 - Python Class 犖犢犢犖犢犖犢犖犖朽権犖о犖園 - Python Class 犖犖 subclass 犖犖迦 Class object 犢犖犖÷賢 Demo: - create class - constructor and destructor - create class instance - using class
  • 15. Read and Write File open(鍖lename, mode) r = read # 犢犖犖巌犢犖犖ム犢犖犖劇犖犖犢犖迦 w = write # 犢犖犖巌犢犖犖ム犢犖犖劇犖犢犖犖朽権犖犖犖園 a = append # 犢犖犖巌犢犖犖ム犢犖犖劇犖犢犖犖朽権犖犖犢犖 鍖le = open(鍖lename.txt, r) 鍖le.read() # 犖犢犖迦犢犖犖ム犖犖園犖犖犖÷犢犖犢犖 String 鍖le.readline() # 犖犢犖迦犢犖犖ム犖犖朽献犖萎犖犖犖犖園 鍖le.readlines() # 犖犢犖迦犢犖犖ム犖犖伍犖犖犖犖犖園犖犖犖犖÷顕犢犖犢犖 List of String 鍖le.write(string) # 犢犖犖朽権犖 String 犖犖園犖犖犖÷犖ム犢犖犖ム 鍖le.writelines([list of string]) # 犢犖犖朽権犖 List of String 犖ム犢犖犖ム
  • 17. Tools Editor - Vim - Sublime Interactive Shell - python shell - ipython IDE - bpython - Eclipse + PyDev - IDLE - Eric IDE - Komodo
  • 18. Libraries Libraries 犖犖犖 Python 犖÷元犢犖∇賢犖萎検犖迦 犖犖迦犖犢犖犖迦 PyPI - http://pypi.python.org/pypi
  • 19. Its Application Digital Image Processing (Python Imaging Library) Computer Vision (OpenCV) Web Framework (Django) Web Server (Gunicorn, Tornado) Web Client (Beautiful Soup, urllib3, html5lib) Content Management System (Plone) Natural Language Processing (NLTK)