Neco 2020 Computer Studies Question 8
Practice essay / theory question 8 from the 2020 Neco Computer Studies examination. This question covers Python programming, File handling, Control structures, Algorithm analysis .
A teacher wants to keep a record of her class’s performance using a simple Python program. The program must read a text file named "scores.txt". Each line of the file contains a student’s name and their score (an integer between 0 and 100) separated by a comma, for example: John Doe,78 Jane Smith,85 ... The program should: 1. Compute the class average. 2. Identify the highest and lowest scores together with the corresponding student names. 3. Assign a grade to each student using the following scale: 70‑100 = A, 60‑69 = B, 50‑59 = C, 40‑49 = D, below 40 = F. 4. Write a new file "report.txt" that lists each student’s name, score, grade and, on the last line, the class average. Below is a draft of the program written by a student. It contains two logical errors. ```python with open('scores.txt', 'r') as f: lines = f.readlines() total = 0 count = 0 high = 0 low = 101 for line in lines: name, sc = line.split(',') score = int(sc) total += score count += 1 if score > high: high = score if score < low: low = score average = total / count with open('report.txt', 'w') as f: for line in lines: name, sc = line.split(',') score = int(sc) if score >= 70: grade = 'A' elif score >= 60: grade = 'B' elif score >= 50: grade = 'C' elif score >= 40: grade = 'D' else: grade = 'F' f.write(f"{name},{score},{grade}\n") f.write(f"Class Average: {average}\n") ``` Answer the following questions:
Question Parts
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 AnswerAbout This Question
This is Neco 2020 Computer Studies Question 8. It is one of the essay questions from the 2020 Neco Computer Studies examination.
The question covers Python programming, File handling, Control structures, Algorithm analysis .
Master the Exam!
You've seen a preview, but there are thousands more questions plus AI tutor to break down complex solutions.