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

回答編集履歴

1

Fix code

2020/08/06 07:15

投稿

y_shinoda
y_shinoda

スコア3272

answer CHANGED
@@ -9,10 +9,10 @@
9
9
  examinee_score = randint(0, 100)
10
10
  score[examinee_number] = examinee_score
11
11
  print(f"受験番号{examinee_number:>3}番:{examinee_score:>3}点")
12
- ave=sum(score)/len(score)
12
+ ave=sum(score.values())/len(score)
13
13
  print(f"\n平均点:{ave:.1f}点")
14
- print(f"最高点:{max(score)}点")
14
+ print(f"最高点:{max(score.values())}点")
15
- print(f"最低点:{min(score)}点")
15
+ print(f"最低点:{min(score.values())}点")
16
16
  print("\n合格者(60点以上) :")
17
17
  points={number: score for number, score in score.items() if score >= 60}
18
18
  for number, score in points.items():
@@ -24,19 +24,19 @@
24
24
  ```console
25
25
  $ python test.py
26
26
  受験者数は?:5
27
- 受験番号 1番: 31
27
+ 受験番号 1番: 48
28
- 受験番号 2番: 47
28
+ 受験番号 2番: 9
29
- 受験番号 3番: 54
29
+ 受験番号 3番: 15
30
- 受験番号 4番:100点
31
- 受験番号 5番: 85
30
+ 受験番号 4番: 81
31
+ 受験番号 5番: 79点
32
32
 
33
- 平均点:3.0
33
+ 平均点:46.4
34
- 最高点:5
34
+ 最高点:81
35
- 最低点:1
35
+ 最低点:9
36
36
 
37
37
  合格者(60点以上) :
38
- 受験番号 4番:100点
39
- 受験番号 5番: 85
38
+ 受験番号 4番: 81
39
+ 受験番号 5番: 79点
40
40
  ```
41
41
 
42
42
  参考: [5.5. 辞書型 (dictionary) | 5. データ構造 — Python 3.8.5 ドキュメント](https://docs.python.org/ja/3/tutorial/datastructures.html#dictionaries)