回答編集履歴

1

a

2018/10/06 15:26

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  self.draw = 0
26
26
 
27
-
27
+
28
28
 
29
29
  def get_winrate(self):
30
30
 
@@ -96,15 +96,23 @@
96
96
 
97
97
  teams = [Carp, Tigers, BayStars, Giants, Dragons, Swallows]
98
98
 
99
+
100
+
101
+ # header
102
+
103
+ print('{:10s} {:3s} {:4s} {:4s} {:6s}'.format(
104
+
105
+ 'team', 'win', 'lose', 'draw', 'rate'))
106
+
99
107
  for team in teams:
100
108
 
101
109
  winrate = team.get_winrate()
102
110
 
103
- print(f'{team.name:10s} {team.win:3d} {team.lose:3d} {team.draw:3d} {winrate:.2%}')
111
+ print(f'{team.name:<10s} {team.win:<3d} {team.lose:<4d} {team.draw:<4d} {winrate:<6.2%}')
104
112
 
105
113
  # Python 3.6 以前なら format() を使う。
106
114
 
107
- # print('{0.name:10s} {0.win:3d} {0.lose:3d} {0.draw:3d} {1:.2%}'.format(
115
+ # print('{0.name:10s} {0.win:3d} {0.lose:3d} {0.draw:3d} {1:5.2%}'.format(
108
116
 
109
117
  # team, team.get_winrate()))
110
118
 
@@ -118,16 +126,18 @@
118
126
 
119
127
  ```
120
128
 
121
- Carp 88 51 4 83.02%
129
+ team win lose draw rate
122
130
 
123
- Tigers 78 61 4 61.90%
131
+ Carp 88 51 4 83.02%
124
132
 
125
- BayStars 73 65 5 54.07%
133
+ Tigers 78 61 4 61.90%
126
134
 
127
- Giants 72 68 3 51.80%
135
+ BayStars 73 65 5 54.07%
128
136
 
129
- Dragons 59 79 5 36.20%
137
+ Giants 72 68 3 51.80%
130
138
 
139
+ Dragons 59 79 5 36.20%
140
+
131
- Swallows 45 96 2 23.20%
141
+ Swallows 45 96 2 23.20%
132
142
 
133
143
  ```