Aruneko
November 09, 2017
230

ゆるいPython会

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

Aruneko

November 09, 2017

Transcript

1. ΏΔ͘ͳ͍1ZUIPOձ
*UFSBCMF(FOFSBUPS-BNCEB
!BSVOFLP

2. ࠓ೔ͷ಺༰
w *UFSBCMF(FOFSBUPS
w -BNCEBࣜ

3. αϯϓϧίʔυ
w IUUQTHJUBSVOFLPOFUBSVOFLPSPVHI@QZUIPO

4. *UFSBCMF
w *UFSBCMFͬͯʁ
w ܁Γฦ͠ॲཧ͕Ͱ͖Δ΋ͷ
w MJTUUVQMFEJDUFUD
w 1ZUIPOʹ͓͍ͯ͸ɺ*UFSBUPSͱ͸ҧ͏Α
w *UFSBUPS͸JUFS
Λ࢖ͬͯ*UFSBCMFͳ΋ͷ͔Βੜ੒ͯ͠
஋ΛOFYU
ͰݸͣͭऔΓग़͢΍ͭ
w શ෦ు͖ग़ͨ͠ޙʹOFYU
ΛݺͿͱྫ֎Ͱམͪ·͢

5. (FOFSBUPS
w (FOFSBUPSͬͯʁ
w *UFSBUPSͷҰछ
w ஋Λੜ੒͢ΔϧʔϧΛ͍࣋ͬͯͯɺݺ͹ΕΔ౓ʹॱ൪ʹు͖ग़͢΍ͭ
w ࠷ޙ·Ͱు͖ग़ͨ͠ޙʹ΋͏ҰճݺΜͰ΋མͪ͸͠ͳ͍͚ͲԿ΋ు͔ͳ͍Α
w ཁ͢Δʹ஗ԆධՁ
w MJTUͳͲ͸σʔλ͕શ෦ϝϞϦʹ৐ͬͯ͠·͏ͷͰɺ
਺͕ଟ͍ͱ͖͸(FOFSBUPSͷํ͕লϝϞϦ
w ͨͩ͠଎͍͔Ͳ͏͔͸ผ໰୊

6. (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)

7. ࿅श໰୊
w 'J[[#V[[Λు͖ग़͢δΣωϨʔλΛ࡞ͬͯΈΑ͏ʂ
w 'J[[#V[[ͱ͸ɺҎ্ͷ੔਺ྻʹରͯ͠
w ͷഒ਺͸'J[[
w ͷഒ਺͸#V[[
w ͷഒ਺͸'J[[#V[[
w ͦΕҎ֎͸ࣗ਎ͷ਺
w Λग़ྗ͢Δ໰୊Ͱ͢

8. -BNCEBࣜ
w ͍͍ͪͪؔ਺Λ࡞Δ·Ͱ΋ͳ͍ͱ͖ʹ࢖͏ؔ਺Ϧςϥϧ
w Ϧςϥϧͬͯͷ͸ม਺ʹ୅ೖͰ͖Δ஋ͷࣄͶ
w ؔ਺ΛҾ਺ʹऔΔؔ਺ʹ࢖͏ͱΑ͛͞
w ͜͏͍͏ؔ਺Λߴ֊ؔ਺ )JHIFS0SEFS'VODUJPO
ͬͯݺͿΑ

9. 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 Ҿ਺ͷॱ൪ʹҰ؏ੑ͕ͳ͍ͷ͸ಥͬࠐΜͰ͸͍͚ͳ͍

10. ࢖ͬͯΈΑ͏
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:
decoded = map(lambda l: l.decode('UTF-8'), splitted_response)
iris_csv = list(map(lambda l: l.split(','), decoded))
iris_data = iris_csv[1:]
iris = map(lambda i: {