College

It is the galactic year 62.53. The Cruz Space Synergy Industries (CSSI) has grown so much that it cannot find enough scientists and engineers to hire. Therefore, the company created the Cruz Space College (CSC) to train the next generation of space scientists and engineers. The company is keeping track of its students’ information using an old system of text files but plans to implement a new system soon. Your job for this project is to ensure that the data in the files is not corrupted.

Write a program that:

1. Asks the user for an input file name.
2. Validates that the user entered a valid file name (name of an existing file).
- If the user enters invalid file names 3 times, displays an error message and quits.
3. Reads from the input file the names of students (don’t make assumptions about how many students) and their grades (0 to 5 grades per student, default to 0).
- The names of the students and the grades will be stored in a dictionary where the names are the keys, and the grades are stored in a list associated with the key.
4. After reading the student information into the dictionary, displays the name of each student followed by their grades and the grade average to the console as follows:
- 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
- Student 3 Grade 1 Grade 2 Grade 3 Grade 4 Grade 5 Average
- Student 4 Grade 1 Grade 2 Grade 3 Grade 4 Grade 5 Average

Example Dictionary + List:

```plaintext
{Student1: [Grade1, Grade2, Grade3, Grade4, Grade5],
Student2: [Grade1, Grade2, Grade3, Grade4, Grade5],
Student3: [Grade1, Grade2, Grade3, Grade4, Grade5]}
```

Structure of input file:

```plaintext
Student 1 Name
Student 1 Grade 1
Student 1 Grade 2
Student 2 Name
Student 3 Name
Student 3 Grade 1
Student 4 Name
Student 4 Grade 1
Student 4 Grade 2
Student 4 Grade 3
Student 4 Grade 4
Student 4 Grade 5
```

For Example:

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

Submission guidelines: Send your `Assignment4.txt` file as an attachment to my email, with the subject "Assignment 4."

Note: Please include the header at the top of your program. Replace the necessary information.

Answer :

Design and develop a program in Python that validates and reads student information from a text file, stores it in a dictionary, and calculates the average grades for each student. The program should ask the user for an input file name, validate the file name, and display the student names, their grades, and the grade average to the console.

To implement the program, we can follow these steps:

1. Prompt the user to enter an input file name and validate if it exists. If the user enters an invalid file name three times, display an error message and quit the program.

2. Read the student information from the input file. Each student's name is followed by their grades, which are stored in a list. Create a dictionary where the student names are the keys and the grades are stored as values associated with each key.

3. Iterate over the dictionary and display the name of each student, followed by their grades and the average grade. Calculate the average grade by summing up the grades and dividing by the number of grades.

4. Display the student information to the console in the specified format, with each student's grades displayed on a separate line.

By following these steps, the program will effectively read and validate the student information from the input file, store it in a dictionary, and display the student names, grades, and average grades to the console.

Learn more about Python

brainly.com/question/30391554

#SPJ11

Other Questions