質問編集履歴

5

コードの修正

2021/01/07 13:18

投稿

penpineapple
penpineapple

スコア2

test CHANGED
File without changes
test CHANGED
@@ -42,7 +42,7 @@
42
42
 
43
43
 
44
44
 
45
- def average_2d_horizontal(li_2d: list) -> list:
45
+ def average_2d(li_2d: list) -> list:
46
46
 
47
47
  result = []
48
48
 
@@ -102,9 +102,9 @@
102
102
 
103
103
  [1.5, 2.5, 3, 4, 5, 6.5]]
104
104
 
105
- print('No1', average_2d_horizontal(li_2d_no1))
105
+ print('No1', average_2d(li_2d_no1))
106
106
 
107
- print('No2', average_2d_horizontal(li_2d_no2))
107
+ print('No2', average_2d(li_2d_no2))
108
108
 
109
109
 
110
110
 

4

コードの微修正

2021/01/07 13:18

投稿

penpineapple
penpineapple

スコア2

test CHANGED
@@ -1 +1 @@
1
- 二次リストの平均値の算出。もっと綺麗なコードに書き換えたい
1
+ 二次リストの平均値の算出。もっと綺麗なコードに書き換えたい
test CHANGED
@@ -42,7 +42,7 @@
42
42
 
43
43
 
44
44
 
45
- def average_2d(li_2d: list) -> list:
45
+ def average_2d_horizontal(li_2d: list) -> list:
46
46
 
47
47
  result = []
48
48
 
@@ -72,6 +72,8 @@
72
72
 
73
73
  return result
74
74
 
75
+
76
+
75
77
  ```
76
78
 
77
79
 
@@ -100,9 +102,11 @@
100
102
 
101
103
  [1.5, 2.5, 3, 4, 5, 6.5]]
102
104
 
103
- print('No1', average_2d(li_2d_no1))
105
+ print('No1', average_2d_horizontal(li_2d_no1))
104
106
 
105
- print('No2', average_2d(li_2d_no2))
107
+ print('No2', average_2d_horizontal(li_2d_no2))
108
+
109
+
106
110
 
107
111
  ```
108
112
 

3

コードの微修正

2021/01/07 12:03

投稿

penpineapple
penpineapple

スコア2

test CHANGED
File without changes
test CHANGED
@@ -100,9 +100,9 @@
100
100
 
101
101
  [1.5, 2.5, 3, 4, 5, 6.5]]
102
102
 
103
- print('ver1', average_2d(li_2d_no1))
103
+ print('No1', average_2d(li_2d_no1))
104
104
 
105
- print('ver2', average_2d(li_2d_no2))
105
+ print('No2', average_2d(li_2d_no2))
106
106
 
107
107
  ```
108
108
 

2

コードの微修正

2021/01/07 11:58

投稿

penpineapple
penpineapple

スコア2

test CHANGED
File without changes
test CHANGED
@@ -34,9 +34,11 @@
34
34
 
35
35
 
36
36
 
37
- def is_num(val):
37
+ def is_num(val) -> bool:
38
38
 
39
39
  return isinstance(val, int) or isinstance(val, float)
40
+
41
+
40
42
 
41
43
 
42
44
 
@@ -82,35 +84,33 @@
82
84
 
83
85
  if __name__ == '__main__':
84
86
 
85
- li_2d_ver1 = [[1, 2, 3, 4],
87
+ li_2d_no1 = [[1, 2, 3, 4],
86
88
 
87
- [1, 3, 5.5, 7],
89
+ [1, 3, 5.5, 7],
88
90
 
89
- [1, 2.5, 3, 'a'],
91
+ [1, 2.5, 3, 'a'],
90
92
 
91
- ['a', 3, 5, None]]
93
+ ['a', 3, 5, None]]
92
94
 
93
95
 
94
96
 
95
- li_2d_ver2 = [[1, 2, 3, 4, 5, 6],
97
+ li_2d_no2 = [[1, 2, 3, 4, 5, 6],
96
98
 
97
- [None, 3, 5, 7, 9, 11],
99
+ [None, 3, 5, 7, 9, 11],
98
100
 
99
- [1.5, 2.5, 3, 4, 5, 6.5]]
101
+ [1.5, 2.5, 3, 4, 5, 6.5]]
100
102
 
101
- print('ver1', average_2d(li_2d_ver1))
103
+ print('ver1', average_2d(li_2d_no1))
102
104
 
103
- print('ver2', average_2d(li_2d_ver2))
105
+ print('ver2', average_2d(li_2d_no2))
104
-
105
-
106
106
 
107
107
  ```
108
108
 
109
109
  ```result
110
110
 
111
- ver1 [2.5, 4.125, 'illegal', 'illegal']
111
+ No1 [2.5, 4.125, 'illegal', 'illegal']
112
112
 
113
- ver2 [3.5, 'illegal', 3.75]
113
+ No2 [3.5, 'illegal', 3.75]
114
114
 
115
115
  ```
116
116
 

1

実行結果の修正

2021/01/07 11:53

投稿

penpineapple
penpineapple

スコア2

test CHANGED
File without changes
test CHANGED
@@ -108,7 +108,9 @@
108
108
 
109
109
  ```result
110
110
 
111
- [2.5, 4.125, 'illegal', 'illegal']
111
+ ver1 [2.5, 4.125, 'illegal', 'illegal']
112
+
113
+ ver2 [3.5, 'illegal', 3.75]
112
114
 
113
115
  ```
114
116