回答編集履歴

1

追記

2019/01/09 08:55

投稿

can110
can110

スコア38266

test CHANGED
@@ -3,3 +3,77 @@
3
3
  一番単純な解決策は3つのファイルをすべて同じ場所に配置することです。
4
4
 
5
5
  この場合、重複している`myclass.py`ファイル名はどちらか変更する必要があります。
6
+
7
+
8
+
9
+ #### 追記
10
+
11
+ 書いてみました。なおファイル名は分かりやすいように書き換えました。
12
+
13
+ ```Python
14
+
15
+ # persion.py
16
+
17
+ class Person:
18
+
19
+ def __init__(self, name, height, weight):
20
+
21
+ self.name = name
22
+
23
+ self.height = height
24
+
25
+ self.weight = weight
26
+
27
+
28
+
29
+ def bmi(self):
30
+
31
+ print(self.weight / self.height / self.height)
32
+
33
+ ```
34
+
35
+ ```Python
36
+
37
+ # buisiness_persion.py
38
+
39
+ from person import Person
40
+
41
+ class BusinessPerson(Person):
42
+
43
+ def __init__(self, name, height, weight, title):
44
+
45
+ super().__init__(name, height, weight)
46
+
47
+ self.title = title
48
+
49
+
50
+
51
+ def work(self):
52
+
53
+ print(self.title, 'の', self.name,'は働いていてる。')
54
+
55
+ ```
56
+
57
+ ```Python
58
+
59
+ # client.py
60
+
61
+ from buisiness_persion import BusinessPerson
62
+
63
+ bp = BusinessPerson('モミジ', 1.26, 24, 'freshman')
64
+
65
+ bp.bmi()
66
+
67
+ bp.work()
68
+
69
+ ```
70
+
71
+ 実行結果
72
+
73
+ ```
74
+
75
+ 15.11715797430083
76
+
77
+ freshman の モミジ は働いていてる。
78
+
79
+ ```