We appreciate your visit to Task Write a Python program to ensure data integrity for a student grading system Background In the galactic year 62 53 Cruz Space Synergy Industries. This page offers clear insights and highlights the essential aspects of the topic. Our goal is to provide a helpful and engaging learning experience. Explore the content and find the answers you need!

**Task:**

Write a Python program to ensure data integrity for a student grading system.

**Background:**

In the galactic year 62.53, Cruz Space Synergy Industries (CSSI) has expanded so much that it struggles to find enough scientists and engineers. To address this, Cruz Space College (CSC) was established to train future space scientists and engineers. Currently, student information is tracked using an outdated text file system, which will soon be updated. Your task is to ensure the data in these files remains uncorrupted.

**Program Requirements:**

1. **Input Handling:**
- Prompt the user to enter an input file name.
- Validate the entered file name to ensure it exists.
- If the user provides invalid file names three times, display an error message and terminate the program.

2. **Data Processing:**
- Read student names and their grades from the input file. Do not assume a fixed number of students.
- Each student can have 0 to 5 grades; if no grades are present, default to 0.
- Store the data in a dictionary with student names as keys and their grades as values (in a list).

3. **Output:**
- Display each student's name, their grades, and the average grade in the following format:
```
Student 1: Grade 1, Grade 2, Grade 3, Grade 4, Grade 5, Average
Student 2: Grade 1, Grade 2, Grade 3, Grade 4, Grade 5, Average
```

4. **Data Structure Example:**
```python
{
'Student1': [Grade1, Grade2, Grade3, Grade4, Grade5],
'Student2': [Grade1, Grade2, Grade3, Grade4, Grade5],
...
}
```

**Input File Structure:**

- Student names are followed by their grades (one per line):
```
Student 1 Name
Student 1 Grade 1
Student 1 Grade 2
Student 2 Name
Student 3 Name
Student 3 Grade 1
...
```

**Example:**

```
Rodolfo
98.9
99.5
Julio
Pedro
100
Maria
99
99.8
90
80
80
```

**Submission Guidelines:**

- Send your `Assignment4.txt` file as an email attachment with the subject "Assignment 4."
- Include a header at the top of your program with the necessary information replaced.

**Note:** Implement the program using Python, ensuring readability and adherence to the specified requirements.

Answer :

If the file name is invalid, you will have three attempts to enter a valid file name before the program quits.

Here's a Python program that implements the requirements you mentioned:

```python

import os

def validate_file_name(file_name):

return os.path.isfile(file_name)

def read_student_data(file_name):

students = {}

current_student = None

with open(file_name, 'r') as file:

for line in file:

line = line.strip()

if line.startswith('Student'):

student_name = line.split(' ')[1]

current_student = student_name

students[current_student] = []

else:

grade = float(line)

students[current_student].append(grade)

return students

def calculate_average(grades):

return sum(grades) / len(grades)

def display_student_data(students):

for student, grades in students.items():

grade_average = calculate_average(grades)

grade_list = ' '.join(str(grade) for grade in grades)

print(f"{student} {grade_list} {grade_average}")

def main():

attempts = 0

while attempts < 3:

file_name = input("Enter the input file name: ")

if validate_file_name(file_name):

students = read_student_data(file_name)

display_student_data(students)

break

else:

print("Invalid file name. Please try again.")

attempts += 1

if attempts == 3:

print("Exceeded maximum number of attempts. Exiting program.")

if __name__ == '__main__':

main()

```

Make sure to save the above code in a `.py` file, such as `assignment4.py`. When you run the program, it will ask you to enter the input file name. If you enter a valid file name (an existing file), it will read the student information from the file, display each student's grades along with the average. If the file name is invalid, you will have three attempts to enter a valid file name before the program quits.

Note: Please replace the necessary information in the header of the program before submitting it.

To know more about Programming related question visit:

https://brainly.com/question/14368396

#SPJ11

Thanks for taking the time to read Task Write a Python program to ensure data integrity for a student grading system Background In the galactic year 62 53 Cruz Space Synergy Industries. We hope the insights shared have been valuable and enhanced your understanding of the topic. Don�t hesitate to browse our website for more informative and engaging content!

Rewritten by : Barada