![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
The (grades.txt) after exection needs to be single lines. (See attachment)
The expected output is also attached
Here is the question:
This
main() will call create() and then call retrieve()
create() will prompt the user to enter any number of course name / grade pairs and write them to a file named grades.txt. Pressing Enter with no input value on the course name will exit the loop, close the file, print "File was created and closed" and return the bool value True to the main()
retrieve() will open and read grades.txt. The function then will print the course names and scores as shown below. The average score should be calculated as well as a simple GPA and displayed to two decimal places and then return variable used for the GPA to the main() . See sample run below in which 4 course names were entered, but note that more or fewer courses could have been entered.
![Below is the transcription of the text from the provided image, formatted for an educational website:
---
**Expected Output - Grades**
The following are the expected outputs for the courses listed:
1. **CCP1000**
- Expected Grade: 78
2. **MAT1020**
- Expected Grade: 99
3. **DUS2100**
- Expected Grade: 89
---
### Explanation of Listed Content
The information denotes the expected grades for three different courses, identified by their respective course codes. Each course code is followed by the anticipated numeric grade. There are no graphs or diagrams included in the provided image. For each course listed:
- **CCP1000** is expected to have a grade of 78.
- **MAT1020** is expected to have a grade of 99.
- **DUS2100** is expected to have a grade of 89.
These grades may reflect student performance metrics or objectives set by the educational institution.](https://content.bartleby.com/qna-images/question/6c27ad58-94b7-4c49-83a5-4adb7b4c3616/7d71cf91-df04-47aa-b607-384632f922c1/h9xdw2x_thumbnail.png)
![**How to Calculate Your GPA**
The process of recording and calculating GPA (Grade Point Average) typically involves inputting grades for each course. Here's a step-by-step example of how you might do this.
1. **Enter Course Data**
- You start by entering the course name followed by the grade achieved for each course.
```
Enter course name or Enter to quit: COP1000
Enter grade (integer) achieved: 96
```
- You continue this for each course:
```
Enter course name or Enter to quit: MAT2040
Enter grade (integer) achieved: 77
```
```
Enter course name or Enter to quit: PHY2100
Enter grade (integer) achieved: 79
```
2. **Completion of Data Entry**
- Once all courses and grades have been entered, the data entry process is concluded.
```
Enter course name or Enter to quit:
File was created and closed
```
3. **Grade Summary**
- After inputting all the necessary data, you can review the grades for each course:
```
Here are your grades:
COP1000 score is 96
MAT2040 score is 77
PHY2100 score is 79
```
4. **Average Grade and GPA Calculation**
- The average grade among the courses is calculated.
- GPA is also provided based on the entered grades.
```
Average grade among your courses is 84.00. Your GPA is 2.67
```
**Explanation**
- COP1000: Scored 96
- MAT2040: Scored 77
- PHY2100: Scored 79
To calculate the average grade:
- Add all the scores: 96 + 77 + 79 = 252
- Divide by the number of courses: 252 / 3 = 84
The GPA of 2.67 in this context appears to be calculated from the average grade, though usually, the GPA might also take into account the credit hours and the grading scale. It's important to conform to your institution's specific GPA calculation formulas.
This exemplifies a practical scenario of tracking your academic performance and understanding how each grade impacts your overall GPA.](https://content.bartleby.com/qna-images/question/6c27ad58-94b7-4c49-83a5-4adb7b4c3616/7d71cf91-df04-47aa-b607-384632f922c1/17uxv3_thumbnail.png)
![Check Mark](/static/check-mark.png)
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 5 images
![Blurred answer](/static/blurred-answer.jpg)
- 13. Write function quote() that takes as input the name of a file (as a string) and anindex i (as an integer). The file will contain quotes, one per line. The function shouldopen the file, read the file, close the file, and return the i-th quote (i.e. the i-th line in thefile), assuming that the quote numbering starts at 0. Test your solution onfile Wilde_Quotes.txt.>>> quote("Wilde_Quotes.txt", 5)'At twilight, nature is not without loveliness, thoughperhaps its chief use is to illustrate quotations from thepoets.\n'>>> quote("Wilde_Quotes.txt", 0)'A little sincerity is a dangerous thing, and a great dealof it is absolutely fatal.\n'>>> quote("Wilde_Quotes.txt", 23)'Patriotism is the virtue of the vicious. \n'>>>arrow_forwardWrite a function that will open a file and write data that was input by the user. Use the input validator pattern to accept the data from the user and exit when the word 'stop' is entered by the user. Remember to name the function and the variables descriptively. Language is Pythonarrow_forwardpls code in pythonplagiarism: This Boolean function takes two filenames. If any line occurs in both files, return True.If not, return False. I suggest using nested loops. With nested loops, we call the loop that is in thebody of the other loop, the "inner loop". The loop that contains the inner loop is the "outer loop". Openthe second file inside the outer loop:for line1 in file1:file2 = open(fname2)for line2 in file2:Python only lets you read the file once per open, so you need this order of instructions. Make sure yourreturn False is outside of both loops. Otherwise, you will only compare the first two lines of thefiles. Make sure you close the file that gets read repeatedly after the inner loop but still inside the outerloop.Here is some (more complete) pseudocode to get you started:open file 1for line1 in file 1open file 2for line2 in file 2:if line1 == line2:return Trueclose file 2return Falsearrow_forward
- Show two different ways to reset the file position pointer to the beginning of the filearrow_forwardExample problem. You have over 500 lines of code within a file that represent people. Some people(lines) are repeated within the file. Show an example program for how to ignore the repeated people(lines) using loops. The output from your program should read, "A total of # people are in the data file ."No functions can be used to complete this, includes file.readlines.arrow_forward9b_act2. Please help me answer this in python programming.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
![Text book image](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)