Python training stage 1

Click here to load reader

  • date post

    10-Nov-2014
  • Category

    Technology

  • view

    57
  • download

    5

Embed Size (px)

description

Python internal training stage 1

Transcript of Python training stage 1

  • 1. Python part-1 David
  • 2. GOAL Familiar with the History of Python Master Python program structure Master Python data structure Master Python input and output Master Python module Master python function
  • 3. INDEX History Python program structure Python data types Input and output Module Function File IO Network
  • 4. History Interpreted, object-oriented,dynamic data types Guido van Rossum(1989) MONTY PYTHON Design philosophy(elegant,clear,simple) Zen of Python(import this) Indentation CPython, Jython, IPython
  • 5. INDEX History Python program basic Python data structure Input and output Module Function File IO Network
  • 6. Python program basic Python basic data type int,long,oat,complex number(1) string boolean(True, False) Keywords(31) Operators(+-*/) Logical block if else if elif else while for
  • 7. INDEX History Python program basic Python data structure Input and output Module Function File IO Network
  • 8. Python data structure List indexed a= [1,3,a,6,8,9] sliced a[2],a[1:3],a[-1],a[-3:]a[:] concatenation a+[3,4,6] append a.append(18) mutable a[1]=100 len len(a) Tuple Immutable t = 12345, 54321, hello! t[1]=22222 caution t=() type(t)->tuple, t=(1) type(t)->int, tips: add comma Dict Python builtin dictionary, or called map(key-value), quick search names = ['Michael', 'Bob', Tracy'] scores = [95, 75, 85] , d = {'Michael': 95, 'Bob': 75, 'Tracy': 85} d[Bob]
  • 9. INDEX History Python program basic Python data structure Input and output Module Function File IO Network
  • 10. Input and output name = raw_input() print name
  • 11. INDEX History Python program basic Python data structure Input and output Module Function File IO Network
  • 12. Module import module, import, from import basic module os, sys, shutil, urllib, time check the module function dir, help self-dened module(later)
  • 13. INDEX History Python program basic Python data structure Input and output Module Function File IO Network
  • 14. Function function is a object keyword: def structure: def func_name(param): statements(s) pass statement More: Default Argument values Keyword Arguments Arbitrary Argument Lists Unpacking Argument Lists Lambda Expressions Documentation Strings
  • 15. INDEX History Python program basic Python data structure Input and output Module Function File IO Network
  • 16. File IO f = open('/Users/michael/test.txt', r') f.read() f.read(128) f.readlines() f.write(Hello world) f.seek(0) f.close()
  • 17. INDEX History Python program basic Python data structure Input and output Module Function File IO Network
  • 18. Network socket urllib urllib2 httplib
  • 19. Q&A