teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

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

2019/07/21 22:14

投稿

m.t.challenger
m.t.challenger

スコア24

title CHANGED
File without changes
body CHANGED
@@ -6,31 +6,18 @@
6
6
  python3.7.3
7
7
  コード
8
8
  ```class Rectangle():
9
-
10
- def __init__(self, width, length):
9
+ def __init__(self, width, length):
11
-
12
- self.width = width
10
+ self.width = width
13
-
14
- self.length = length
11
+ self.length = length
15
-
16
- def calcurate_perimeter(self):
12
+ def calcurate_perimeter(self):
17
-
18
- return self.width * 2 + self.length * 2
13
+ return self.width * 2 + self.length * 2
19
-
20
14
  class Square():
21
-
22
- def __init__(self, sl):
15
+ def __init__(self, sl):
23
-
24
- self.sl = sl
16
+ self.sl = sl
25
-
26
- def calculate_perimeter(self):
17
+ def calculate_perimeter(self):
27
-
28
- return self.sl * 4
18
+ return self.sl * 4
29
-
30
-
31
19
  a_rectangle = Rectangle(25, 50)
32
20
  a_square = Square(20)
33
-
34
21
  print(a_rectangle.calculate_perimeter())
35
22
 
36
23
  Traceback (most recent call last):

1

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

2019/07/21 22:14

投稿

m.t.challenger
m.t.challenger

スコア24

title CHANGED
File without changes
body CHANGED
@@ -31,4 +31,9 @@
31
31
  a_rectangle = Rectangle(25, 50)
32
32
  a_square = Square(20)
33
33
 
34
- print(a_rectangle.calculate_perimeter())
34
+ print(a_rectangle.calculate_perimeter())
35
+
36
+ Traceback (most recent call last):
37
+ File "<pyshell#34>", line 1, in <module>
38
+ print(a_rectangle.calculate_perimeter())
39
+ AttributeError: 'Rectangle' object has no attribute 'calculate_perimeter'