質問編集履歴

3

hanedaapproachを追加しました

2019/02/15 15:17

投稿

kyonmn
kyonmn

スコア15

test CHANGED
File without changes
test CHANGED
@@ -130,6 +130,8 @@
130
130
 
131
131
  期待される出力
132
132
 
133
+
134
+
133
135
  ```
134
136
 
135
137
  [<simulatesource.hanedaapproach object at 0x105156cc0>, <simulatesource.hanedaapproach object at 0x105156f28>, <simulatesource.hanedaapproach object at 0x105156cf8>, <simulatesource.hanedaapproach object at 0x105156da0>]
@@ -151,3 +153,65 @@
151
153
  [<simulatesource.hanedaapproach object at 0x105156cf8>, <simulatesource.hanedaapproach object at 0x105156da0>]
152
154
 
153
155
  ```
156
+
157
+
158
+
159
+ #
160
+
161
+ 補足
162
+
163
+
164
+
165
+ hanedaapproachのコードは以下の通りです。
166
+
167
+ ```python
168
+
169
+
170
+
171
+ heavylist = ['B77W','B747']
172
+
173
+ mediumlist = ['B763','A333','A332','B789','B788','B78W','A358']
174
+
175
+ lightlist = ['B738','B737','B735','B734','A321','A320','A319']
176
+
177
+ class hanedaapproach:
178
+
179
+ def __init__(self, time, flightnumber, position1, position2,altitude, shipname):
180
+
181
+ self.time = time
182
+
183
+ self.flightnumber = flightnumber
184
+
185
+ self.altitude = altitude
186
+
187
+ self.position1 = position1
188
+
189
+ self.position2 = position2
190
+
191
+ self.shipname = shipname
192
+
193
+
194
+
195
+ def info(self):
196
+
197
+ for i in heavylist:
198
+
199
+ if self.shipname == i:
200
+
201
+ return 'H'
202
+
203
+ for j in mediumlist:
204
+
205
+ if self.shipname == j:
206
+
207
+ return 'M'
208
+
209
+ for k in lightlist:
210
+
211
+ if self.shipname == k:
212
+
213
+ return 'L'
214
+
215
+
216
+
217
+ ```

2

余分なメモが入っておりましたので消去しました

2019/02/15 15:17

投稿

kyonmn
kyonmn

スコア15

test CHANGED
File without changes
test CHANGED
@@ -68,19 +68,13 @@
68
68
 
69
69
  i = i + 1
70
70
 
71
- print(Airplane) # 二重配列になっているかの確認です
72
71
 
73
- print(Airplane[1].position1)
74
72
 
75
- #ALLIE
76
73
 
77
- #N35.4436125
78
-
79
- #E139.85138972222222
80
74
 
81
75
  Airplane1 = []
82
76
 
83
- Airplane2 = [] # からのリストを作っていきます
77
+ Airplane2 = [] # のリストを作っていきます
84
78
 
85
79
 
86
80
 
@@ -116,9 +110,7 @@
116
110
 
117
111
  Airplane2.append('')
118
112
 
119
- print(Airplane1)
113
+
120
-
121
- print (Airplane2)
122
114
 
123
115
  print(Airplane1)
124
116
 
@@ -152,7 +144,7 @@
152
144
 
153
145
  [<simulatesource.hanedaapproach object at 0x105156cc0>, <simulatesource.hanedaapproach object at 0x105156f28>]
154
146
 
155
- [<simulatesource.hanedaapproach object at 0x105156f28>, <simulatesource.hanedaapproach object at 0x105156cc0>,]
147
+ [<simulatesource.hanedaapproach object at 0x105156f28>, <simulatesource.hanedaapproach object at 0x105156cc0>]
156
148
 
157
149
  #削除したデータ
158
150
 

1

iの定義について記述しました

2019/02/15 14:07

投稿

kyonmn
kyonmn

スコア15

test CHANGED
File without changes
test CHANGED
@@ -11,6 +11,78 @@
11
11
 
12
12
 
13
13
  ```Python
14
+
15
+ csvfile = open('testdata.csv')
16
+
17
+ for row in csv.reader(csvfile):
18
+
19
+ print(row) # 一行づつプリントしていきます
20
+
21
+
22
+
23
+ with open('testdata.csv') as fp:
24
+
25
+ lst = list(csv.reader(fp))
26
+
27
+ print(lst)
28
+
29
+ i = 1 # カウンタを置いておきます
30
+
31
+ Airplane = {} # 空の辞書追加
32
+
33
+
34
+
35
+ for l in lst:
36
+
37
+ print (l)
38
+
39
+ print(type(l))
40
+
41
+ for n in l:
42
+
43
+ time = l[0]
44
+
45
+ flightnumber = l[1]
46
+
47
+ position1 = l[2]
48
+
49
+ position2 = l[3]
50
+
51
+ altitude = l[4]
52
+
53
+ shipname = l[5]
54
+
55
+
56
+
57
+ Airplane[i] = hanedaapproach(
58
+
59
+ time, flightnumber, position1, position2, altitude, shipname
60
+
61
+ )
62
+
63
+ # それぞれの値を指定して、空の辞書へ打ち込んでいきます
64
+
65
+
66
+
67
+
68
+
69
+ i = i + 1
70
+
71
+ print(Airplane) # 二重配列になっているかの確認です
72
+
73
+ print(Airplane[1].position1)
74
+
75
+ #ALLIE
76
+
77
+ #N35.4436125
78
+
79
+ #E139.85138972222222
80
+
81
+ Airplane1 = []
82
+
83
+ Airplane2 = [] # からのリストを作っていきます
84
+
85
+
14
86
 
15
87
  Airplane[i] = hanedaapproach(
16
88