Neco 2019 Computer Studies Question 8

Practice essay / theory question 8 from the 2019 Neco Computer Studies examination. This question covers Basic Programming, Python, File I/O, Control Structures, Error Handling .

Neco 2019 Computer Studies Essay / Theory
Topics: Basic Programming Python File I/O Control Structures Error Handling
Question 8 NECO • 2019 • COMPUTER_STUDIES • essay

You are required to develop a Python program that processes a list of student scores and generates a grade report. The grading scale is: A: 70‑100, B: 60‑69, C: 50‑59, D: 45‑49, E: 40‑44, F: 0‑39. The scores are stored in a text file named "scores.txt" where each line contains a student's name and their score separated by a comma (e.g., "Ada,85").

Question Parts

( a )
Write a Python function called `grade_counts(scores)` that takes a list of integer scores (0‑100) and returns a dictionary whose keys are the grades ("A", "B", "C", "D", "E", "F") and whose values are the number of occurrences of each grade.
( b )
Using the function from part (a), write a complete program that: i) Reads the file "scores.txt". ii) Extracts each student's name and score, ignoring any line that does not contain a valid name‑score pair. iii) Calls `grade_counts` to obtain the grade distribution. iv) Writes the distribution to a new file "grade_report.txt" in the format "A: 5" (one grade per line). v) Prints on the screen the total number of students whose records were processed. Include appropriate error handling for missing files and malformed lines.

Detailed Solution & Marking Scheme

Get the step-by-step solution, key points required by examiners and detailed marking guidance through the Edcrib AI Tutor.

Reveal Answer

About This Question

This is Neco 2019 Computer Studies Question 8. It is one of the essay questions from the 2019 Neco Computer Studies examination.

The question covers Basic Programming, Python, File I/O, Control Structures, Error Handling .

Master the Exam!

You've seen a preview, but there are thousands more questions plus AI tutor to break down complex solutions.

Unlock Full Access Available for Android & Windows
Chat with Support