Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
The marks are [72, 85, 64, 90, 58, 91, 60, 74]. Using the grade rules (90 and more A, 75 and more B, 60 and more C, below 60 D), work out by hand how many students got each grade. Then write the program and check it.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Plan. Find the grade of each mark, then count.
The counts add up to 8, the number of students.
The program.
Check. The output is [2, 1, 4, 1], and sum(counts) is 8.
Answer: A 2, B 1, C 4, D 1.
Log in to join the discussion.
Loading…