Skip to content

宿題007-人生の足跡を辿ってみよう。タプルは便利すぎる #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
domanthan opened this issue Aug 31, 2018 · 1 comment

Comments

@domanthan
Copy link
Contributor

domanthan commented Aug 31, 2018

人生の足跡を辿ってみよう。タプルは便利すぎる

© 2018 Gridscale Inc. http://www.gridscale.com

前振り

 Tupleとはn-組のこと。
 https://ja.wikipedia.org/wiki/%E3%82%BF%E3%83%97%E3%83%AB
 形式が整えっているN個のデータから一つのN-Tupleを構成する。
 Tupleにある要素は必ず同じデータタイプでなくでも良い。

    1-Tuple  (A,)                  後ろに[,]があるのを注目してください。
    2-Tuple (A,B)
    3-Tuple (A,B,C)
    
    数学や科学情報に、様々なTupleがある。
 (ID, Password)
   座標 (x,y), (x,y,z)
 地理情報 (経度、緯度)

Tupleのパックとアンパック

  • パック :バラバラの項目を一つのTupleにする。
              t = (1,2,3)  
  • アンパック: Tupleをバラバラの変数にマッピング。
             a,b,c = t

要件説明

 Tupleを利用して、貴方の人生の軌跡を辿ってみてはいかがでしょうか。
 人生は生まれから始まり、その後就学、就職など様々なステージを踏むのが一般でしょ。
 一連の(時間、ステージ、場所)から人生を歩んできたではないでしょうか。
 場所は名称と地理情報で表せれば、地図上で人生の軌跡を描くのも難しい事ではないです。

 では、貴方の人生を下記の様に出力するプログラムを作成してみてください。

私の人生の軌跡:
 -----------------------------------------------------------------
 1969年     誕生     中国の小さい村      地理位置: ( 111 , 222 )
 1976年     小学校     XXX小学校      地理位置: ( 222 , 333 )
 1988年     大学校     中国XXX大学      地理位置: ( 333 , 22 )
 1996年     来日     ABC株式会社      地理位置: ( 322 , 23 )

reference

宿題学習ポイント(Concept)

https://docs.python.org/ja/3/library/stdtypes.html#sequence-types-list-tuple-range

https://docs.python.jp/3/tutorial/datastructures.html#tuples-and-sequences

参考実装

https://github.com/gridscaleinc/Learning-Python/blob/master/domanthan/Less007/Less007.py

言語リファレンス

https://docs.python.org/ja/3/reference/index.html

宿題の提出について

githubに宿題をコミットする際、必ず下記の様なフォルダ構成にしたがって欲しいです。
宿題を完成させたエビデンスファイルも合わせて出してください。できれば。

     ---- 「ご自分のgithubid]  
         ---   less001  
               -- file001.py  
               -- evidence001.txt  
@domanthan domanthan changed the title 宿題006-タプル(便利すぎる)(予定) 宿題007-タプル(便利すぎる)(予定) Aug 31, 2018
@domanthan domanthan changed the title 宿題007-タプル(便利すぎる)(予定) 宿題007-データタイプ(タプルは便利すぎる)(予定) Aug 31, 2018
@domanthan domanthan changed the title 宿題007-データタイプ(タプルは便利すぎる)(予定) 宿題007-人生の足跡を辿ってみよう。タプルは便利すぎる Sep 3, 2018
@dongri
Copy link

dongri commented Sep 3, 2018

DONE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants