Gce Model Questions Vol1 2021 Computer Studies Question 8

Practice essay / theory question 8 from the 2021 Gce Model Questions Vol1 Computer Studies examination. This question covers Python programming, File handling, Functions, List comprehensions, Exception handling, Data processing .

Gce Model Questions Vol1 2021 Computer Studies Essay / Theory
Topics: Python programming File handling Functions List comprehensions Exception handling Data processing
Question 8 GCE_MODEL_QUESTIONS_VOL1 • 2021 • COMPUTER_STUDIES • essay

You are required to develop a Python program that processes a text file named **students.txt**. Each line of the file contains a student's name followed by three integer test scores, separated by commas, for example: ``` Ada,78,85,92 Bola,64,70,58 Chinwe,90,88,95 ``` The program must: 1. Read the data safely, handling possible missing scores or extra whitespace. 2. Compute a weighted average for each student where the first test counts 20%, the second 30% and the third 50%. 3. Determine the class average (mean of all students' weighted averages) and the pass rate (percentage of students whose weighted average is at least 60). 4. Produce a neatly formatted report that lists: - The top three students by weighted average (show name and average); - The overall class average rounded to two decimal places; - The pass rate as a percentage rounded to one decimal place. 5. The program must use at least one user‑defined function, a list comprehension, and appropriate exception handling. Write the complete Python code that fulfils the above requirements and briefly explain how each part of the code meets the specifications.

Question Parts

( a )
Write a function called **weighted_average(scores)** that takes a list of three integer scores and returns the weighted average as a float. Include error checking to ensure the list contains exactly three numeric values; otherwise raise a **ValueError** with an appropriate message.
( b )
Provide the code segment that reads **students.txt**, cleans each line (removing extra spaces), splits the line into name and scores, converts the scores to integers, and stores the data in a list of tuples **(name, scores_list)**. Show how you would handle a line that has missing scores using **try/except** so that the line is skipped with a warning printed to the console.
( c )
Write the remaining part of the program that: i. Uses **weighted_average** to compute each student’s average; ii. Calculates the class average and pass rate; iii. Determines the top three students; iv. Prints the final report in the format shown below. **Sample report** ``` Top 3 Students: 1. Chinwe – 91.90 2. Ada – 86.90 3. Bola – 62.20 Class average: 80.33 Pass rate: 100.0% ```

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 Gce Model Questions Vol1 2021 Computer Studies Question 8. It is one of the essay questions from the 2021 Gce Model Questions Vol1 Computer Studies examination.

The question covers Python programming, File handling, Functions, List comprehensions, Exception handling, Data processing .

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