Skip to content

WahabAG/TC_MC_Python_FileTask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TC_MC_Python_FileTask

Average Score Calculator (Python) 📘 Overview

This Python program reads student data from a CSV file and calculates the average score from the “Score” column. It uses Python’s built-in csv module and includes proper error handling for missing files, invalid data, or missing columns.

Features

Reads a .csv file and converts each row into a dictionary.

Calculates the average of all valid scores in the “Score” column.

Ignores empty or invalid values.

Handles common errors gracefully (e.g., missing file or column).

Displays the average formatted to 2 decimal places.

📂 Project Structure TC_MC_Python_FileTask/ │ ├── attendance_score.csv # Input CSV file ├── main.py # Python script (code shown below) └── README.md # Project documentation

💻 Example CSV File

attendance_score.csv

Sn,Name,Mat_no,Score 1,Azeez,142142,78 2,Mary,142143,90 3,John,142144,82 4,Ruth,142145,85

How It Works

Opens the CSV file using Python’s with open() statement.

Uses csv.DictReader() to read each line as a dictionary.

Collects all valid scores, converts them to float, and stores them in a list.

Calculates the average using sum(scores) / len(scores).

Prints the formatted average.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages