Aruneko
November 09, 2017
230

# ゆるいPython会

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

## Aruneko

November 09, 2017

## Transcript

4. ### *UFSBCMF w *UFSBCMFͬͯʁ w ܁Γฦ͠ॲཧ͕Ͱ͖Δ΋ͷ w MJTUUVQMFEJDUFUD 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 Λग़ྗ͢Δ໰୊Ͱ͢

ͬͯݺͿΑ
9. ### 1ZUIPOͷߴ֊ؔ਺ w *UFSBCMFͳΦϒδΣΫτΛҰׅͰૢ࡞͢Δؔ਺ w NBQ GVOD JUFS  w pMUFS

GVOD JUFS  w GVODUPPMTSFEVDF GVOD JUFS  w ೚ҙॱͰͷιʔτ w TPSUFE JUFS LFZLFZ@GVODUJPO  w άϧʔϓ෼͚ w JUFSUPPMTHSPVQCZ JUFS LFZLFZ@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:

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)
11. ### ࿅श໰୊ w JSJTQZΛվ଄͠Α͏ w ଞͷ஋Ͱ΋ιʔτͯ͠ΈΑ͏ w SFEVDFΛ࢖ͬͯͭͷ஋ TFQBMͱQFUBMͷXJEUIͱMFOHUI ͷ  ฏۉ஋ΛͦΕͧΕٻΊͯΈΑ͏

TVNറΓ  w ࠓ౓͸Ֆͷछྨ͝ͱʹಉ͡ࣄΛ΍ͬͯΈΑ͏ HSPVQCZ