Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ゆるいPython会

Aruneko
November 09, 2017

 ゆるいPython会

2017/11/09に学内で開催したゆる(くな)いPython会の資料です

Aruneko

November 09, 2017
Tweet

More Decks by Aruneko

Other Decks in Technology

Transcript

  1. *UFSBCMF w *UFSBCMFͬͯʁ w ܁Γฦ͠ॲཧ͕Ͱ͖Δ΋ͷ w MJTUUVQMFEJDUFUD w 1ZUIPOʹ͓͍ͯ͸ɺ*UFSBUPSͱ͸ҧ͏Α w

    *UFSBUPS͸JUFS Λ࢖ͬͯ*UFSBCMFͳ΋ͷ͔Βੜ੒ͯ͠
 ஋ΛOFYU ͰݸͣͭऔΓग़͢΍ͭ w શ෦ు͖ग़ͨ͠ޙʹOFYU ΛݺͿͱྫ֎Ͱམͪ·͢
  2. (FOFSBUPS w (FOFSBUPSͬͯʁ w *UFSBUPSͷҰछ w ஋Λੜ੒͢ΔϧʔϧΛ͍࣋ͬͯͯɺݺ͹ΕΔ౓ʹॱ൪ʹు͖ग़͢΍ͭ w ࠷ޙ·Ͱు͖ग़ͨ͠ޙʹ΋͏ҰճݺΜͰ΋མͪ͸͠ͳ͍͚ͲԿ΋ు͔ͳ͍Α w

    ཁ͢Δʹ஗ԆධՁ w MJTUͳͲ͸σʔλ͕શ෦ϝϞϦʹ৐ͬͯ͠·͏ͷͰɺ
 ਺͕ଟ͍ͱ͖͸(FOFSBUPSͷํ͕লϝϞϦ w ͨͩ͠଎͍͔Ͳ͏͔͸ผ໰୊
  3. (FOFSBUPSΛ࡞ͬͯΈΔ def gen_odd_numbers(min: int, max: int) -> [int]: for n

    in range(min, max): yield 2 * n + 1 nums = gen_odd_numbers(0, 100) for n in nums: print(n)
  4. 1ZUIPOͷߴ֊ؔ਺ w *UFSBCMFͳΦϒδΣΫτΛҰׅͰૢ࡞͢Δؔ਺ w NBQ GVOD JUFS  w pMUFS

    GVOD JUFS  w GVODUPPMTSFEVDF GVOD JUFS  w ೚ҙॱͰͷιʔτ w TPSUFE JUFS LFZLFZ@GVODUJPO  w άϧʔϓ෼͚ w JUFSUPPMTHSPVQCZ JUFS LFZLFZ@GVODUJPO  w ͍ͭ͜ΒͷฦΓ஋͸શ෦(FOFSBUPSͳͷͰऔѻ஫ҙ w Ҿ਺ͷॱ൪ʹҰ؏ੑ͕ͳ͍ͷ͸ಥͬࠐΜͰ͸͍͚ͳ͍
  5. ࢖ͬͯΈΑ͏ import urllib.request iris_url = 'https://raw.githubusercontent.com/uiuc-cse/data-fa14/gh-pages/data/iris.csv' with urllib.request.urlopen(iris_url) as res:

    splitted_response = res.read().split() decoded = map(lambda l: l.decode('UTF-8'), splitted_response) iris_csv = list(map(lambda l: l.split(','), decoded)) header = iris_csv[0] iris_data = iris_csv[1:] iris = map(lambda i: { header[4]: i[4], header[0]: float(i[0]), header[1]: float(i[1]), header[2]: float(i[2]), header[3]: float(i[3]) }, iris_data ) for l in sorted(iris, key=lambda i: i['sepal_width']): print(l)