forked from abhaysamantni/PythonReview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNestedForLoopsTestAverages.py
More file actions
31 lines (21 loc) · 935 Bytes
/
NestedForLoopsTestAverages.py
File metadata and controls
31 lines (21 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Get the number of students.
num_students = int(input('How many students do you have? '))
# Get the number of test scores per student.
num_test_scores = int(input('How many test scores per student? '))
# Determine each students average test score.
for student in range(num_students):
# Initialize an accumulator for test scores.
total = 0.0
# Get a student's test scores.
print('Student number', student + 1)
print('-----------------')
for test_num in range(num_test_scores):
print('Test number', test_num + 1, end='')
score = float(input(': '))
# Add the score to the accumulator.
total += score
# Calculate the average test score for this student.
average = total / num_test_scores
# Display the average.
print('The average for student number', student + 1, 'is:', format(average, '.1f'))
print()