質問編集履歴

2

コードの空白をなくしました。

2019/07/21 22:14

投稿

m.t.challenger
m.t.challenger

スコア24

test CHANGED
File without changes
test CHANGED
@@ -14,55 +14,29 @@
14
14
 
15
15
  ```class Rectangle():
16
16
 
17
+ def __init__(self, width, length):
17
18
 
19
+ self.width = width
18
20
 
19
- def __init__(self, width, length):
21
+ self.length = length
20
22
 
23
+ def calcurate_perimeter(self):
21
24
 
22
-
23
- self.width = width
24
-
25
-
26
-
27
- self.length = length
28
-
29
-
30
-
31
- def calcurate_perimeter(self):
32
-
33
-
34
-
35
- return self.width * 2 + self.length * 2
25
+ return self.width * 2 + self.length * 2
36
-
37
-
38
26
 
39
27
  class Square():
40
28
 
29
+ def __init__(self, sl):
41
30
 
31
+ self.sl = sl
42
32
 
43
- def __init__(self, sl):
33
+ def calculate_perimeter(self):
44
34
 
45
-
46
-
47
- self.sl = sl
48
-
49
-
50
-
51
- def calculate_perimeter(self):
52
-
53
-
54
-
55
- return self.sl * 4
35
+ return self.sl * 4
56
-
57
-
58
-
59
-
60
36
 
61
37
  a_rectangle = Rectangle(25, 50)
62
38
 
63
39
  a_square = Square(20)
64
-
65
-
66
40
 
67
41
  print(a_rectangle.calculate_perimeter())
68
42
 

1

エラーメッセージを書き込みました。

2019/07/21 22:14

投稿

m.t.challenger
m.t.challenger

スコア24

test CHANGED
File without changes
test CHANGED
@@ -65,3 +65,13 @@
65
65
 
66
66
 
67
67
  print(a_rectangle.calculate_perimeter())
68
+
69
+
70
+
71
+ Traceback (most recent call last):
72
+
73
+ File "<pyshell#34>", line 1, in <module>
74
+
75
+ print(a_rectangle.calculate_perimeter())
76
+
77
+ AttributeError: 'Rectangle' object has no attribute 'calculate_perimeter'