授業-ソフトウェア工学 > 2018年度 > 第11回


授業-2018年度-ソフトウェア工学-第11回

*

(公開)





お知らせ

  • アンケートと課題の提出
*


概要


概念編

  • 概要


実習編

  • 概要
*


配布資料

*


今回の内容


概念編

  • 内容


実習編

  • 内容
*


プログラムの説明 (例題と課題)

[ edit ]

  • ファイル入出力
    • 基本的なファイル入出力
      • オープンとクローズ
      • with文
    • CSVファイルの取り扱い
    • 【基本課題1】単語の出現頻度表
    • 【基本課題2】都道府県ごとの統計(面積,人口,人口密度)
      • 情報源
      • データファイル(県別の情報だけを抽出してありますので,これをcsvファイルとして保存してください)
        • prefecture_data_2015a-processed.xls

        • CSVファイルに変換して,入力データにしましょう.下記リンクよりダウンロードしても結構です(注).
          • prefecture_data_2015a-processed.csv→(注)サーバのトラブルで一時的にCSVファイルがうまく掲載できないので,下記より,Copy&Pasteしてください

,,人口,面積,人口密度,平均年齢
00,全国,"127,094,745","377,970.75",340.8,46.4 
01,北海道,"5,381,733","83,424.31",68.6,48.3 
02,青森県,"1,308,265","9,645.59",135.6,49.0 
03,岩手県,"1,279,594","15,275.01",83.8,49.0 
04,宮城県,"2,333,899","7,282.22",320.5,46.2 
05,秋田県,"1,023,119","11,637.54",87.9,51.3 
06,山形県,"1,123,891","9,323.15",120.5,49.1 
07,福島県,"1,914,039","13,783.74",138.9,48.2 
08,茨城県,"2,916,976","6,097.06",478.4,46.7 
09,栃木県,"1,974,255","6,408.09",308.1,46.4 
10,群馬県,"1,973,115","6,362.28",310.1,46.9 
11,埼玉県,"7,266,534","3,797.75","1,913.4",45.4 
12,千葉県,"6,222,666","5,157.65","1,206.5",46.0 
13,東京都,"13,515,271","2,190.93","6,168.7",44.7 
14,神奈川県,"9,126,214","2,415.83","3,777.7",45.0 
15,新潟県,"2,304,264","12,584.10",183.1,48.5 
16,富山県,"1,066,328","4,247.61",251.0,48.4 
17,石川県,"1,154,008","4,186.09",275.7,46.7 
18,福井県,"786,740","4,190.49",187.7,47.4 
19,山梨県,"834,930","4,465.27",187.0,47.6 
20,長野県,"2,098,804","13,561.56",154.8,48.2 
21,岐阜県,"2,031,903","10,621.29",191.3,46.9 
22,静岡県,"3,700,305","7,777.42",475.8,47.0 
23,愛知県,"7,483,128","5,172.48","1,446.7",44.3 
24,三重県,"1,815,865","5,774.40",314.5,46.9 
25,滋賀県,"1,412,916","4,017.38",351.7,44.5 
26,京都府,"2,610,353","4,612.19",566.0,46.3 
27,大阪府,"8,839,469","1,905.14","4,639.8",45.8 
28,兵庫県,"5,534,800","8,400.96",658.8,46.5 
29,奈良県,"1,364,316","3,690.94",369.6,47.2 
30,和歌山県,"963,579","4,724.69",203.9,48.7 
31,鳥取県,"573,441","3,507.05",163.5,48.2 
32,島根県,"694,352","6,708.24",103.5,49.5 
33,岡山県,"1,921,525","7,114.50",270.1,46.9 
34,広島県,"2,843,990","8,479.45",335.4,46.5 
35,山口県,"1,404,729","6,112.30",229.8,49.0 
36,徳島県,"755,733","4,146.65",182.3,49.0 
37,香川県,"976,263","1,876.72",520.2,48.0 
38,愛媛県,"1,385,262","5,676.11",244.1,48.6 
39,高知県,"728,276","7,103.93",102.5,49.8 
40,福岡県,"5,101,556","4,986.40","1,023.1",45.7 
41,佐賀県,"832,832","2,440.68",341.2,46.8 
42,長崎県,"1,377,187","4,132.09",333.3,48.2 
43,熊本県,"1,786,170","7,409.35",241.1,47.5 
44,大分県,"1,166,338","6,340.71",183.9,48.3 
45,宮崎県,"1,104,069","7,735.31",142.7,47.9 
46,鹿児島県,"1,648,177","9,186.94",179.4,48.1 
47,沖縄県,"1,433,566","2,281.12",628.4,42.1 
  • BP_05_002a_prefecture_info.py

    • 人口密度を求めて,統計データが正しいかどうか確認してください.
    • 人口密度の順番に並べ替えてみましょう
  • 回答例 ←授業中にやったところまで

    ,   東京,  品川, 新横浜, 名古屋,   京都, 新大阪
東京,      0,     0,      0,      0,      0,      0
品川,    170,     0,      0,      0,      0,      0
新横浜,  500,   410,      0,      0,      0,      0
名古屋, 6260,  6260,   5620,      0,      0,      0
京都,   8210,  8210,   7880,   2590,      0,      0
京都,   8750,  8750,   8420,   3350,    560,      0
  • 特急料金表→サーバのトラブルで一時的にCSVファイルがうまく掲載できないので,下記より,Copy&Pasteしてください

    ,   東京,  品川, 新横浜, 名古屋,   京都, 新大阪
東京,      0,     0,      0,      0,      0,      0
品川,    860,     0,      0,      0,      0,      0
新横浜,  860,   860,      0,      0,      0,      0
名古屋, 4100,  4100,   4100,      0,      0,      0
京都,   4870,  4870,   4540,   2480,      0,      0
京都,   4870,  4870,   4870,   2480,    860,      0
  • 例外処理
    • 今回は,基本的な内容にとどめましょう
      • よく見かける例外と,その対応の例を示します.
      • ユーザ定義例外などは,高度な内容なので,今回は取り扱いません.
    • よく見かける例外
      • 実行時エラーの捕捉と対応
        • 数値計算
        • 組込み関数やメソッドでの値エラー(ValueError 例外)と型エラー(TypeError)

        • データ操作
          • リスト操作(シーケンス操作)での添え字エラー(IndexError 例外)

      • 辞書アクセスでのキーエラー(KeyError例外)

      • キーボード割込み
      • ファイル操作/入出力関係
*


授業の狙いと特徴

[ edit ] ⇒ HandOut

*


*


*

SoftEng: 2018/11 (last edited 2018-09-25 15:42:10 by TadashiIijima)