Skip to content

Commit f4d14af

Browse files
authored
Add files via upload
Nested loop example, which prints out the number of students who got at least one failed score
1 parent 38a59b7 commit f4d14af

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Use case 4: Check to see how many students have failed a test (nested loop)
2+
scores = [
3+
[90, 30, 80, 100],
4+
[100, 80, 95, 87],
5+
[75, 84, 77, 90]
6+
]
7+
8+
failed_score = 60
9+
num_failed_students = 0
10+
for score_set in scores:
11+
for score in score_set:
12+
if score < failed_score:
13+
num_failed_students += 1
14+
break
15+
print("Number of students who failed a test: " + str(num_failed_students))

0 commit comments

Comments
 (0)