Skip to content

宿題015-地球一年の移動距離、速度速度、自転速度を計算、クラスの定義を練習 #15

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 Sep 3, 2018 · 0 comments

Comments

@domanthan
Copy link
Contributor

domanthan commented Sep 3, 2018

地球一年の移動距離、速度速度、自転速度を計算、クラスの定義を練習

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

前振り

地球はとても孤独なんです。生き物が生息している惑星は他に知らないからです。
来る日も来る日も、地球は太陽を中心に回り続けているが、一年間地球が動いた距離はわかりますか。

要件説明

. 地球と太陽の間の距離は 149,600,000 km
. 地球の半径 6371 km
. 太陽の中心を円心として、地球は一年間一つの円を描く。
その円の周長を計算しましょう。

1)まず、円(Circle)というクラスを定義
半径という属性をもち、周長を計算できるメソッドをもつ。

2)惑星(Planet)というクラスを定義
  公転周期という属性を持ち

3)地球(Globe)というクラスを定義
  条件: 円、惑星クラスを継承してください。
      コンストラクター init()をしっかり定義してください。

  属性: 自転周期 (ヒント: 一日何秒?)
  メソッド: 自転速度を計算 (rotation)
  メソッド: 公転速度を計算 (revolution)

結果:
地球は一年間 : 939488000.0 kmを太陽の周りで回ってます。
地球の公転速度は : 29.79 km/s
地球の自伝速度は : 0.46 km/s

reference

宿題学習ポイント(Concept)

クラスの定義:
https://docs.python.jp/3/tutorial/classes.html#class-definition-syntax

クラスの多重継承:
https://docs.python.jp/3/tutorial/classes.html#multiple-inheritance

クラス定義の注意点:
https://docs.python.jp/3/tutorial/classes.html#random-remarks

super()関数の呼び出し方:
https://docs.python.jp/3/library/functions.html#super

参考実装

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

言語リファレンス

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

宿題の提出について

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

     ---- 「ご自分のgithubid]  
         ---   less001  
               -- file001.py  
               -- evidence001.txt  
@domanthan domanthan changed the title 宿題015-クラスの定義  宿題015-移動体としての車、クラスの定義  Oct 6, 2018
@domanthan domanthan changed the title 宿題015-移動体としての車、クラスの定義  宿題015-地球一年の移動距離、クラスの定義を練習  Oct 6, 2018
@domanthan domanthan changed the title 宿題015-地球一年の移動距離、クラスの定義を練習  宿題015-地球一年の移動距離、速度速度、自転速度を計算、クラスの定義を練習 Oct 6, 2018
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

1 participant