The (grades.txt) after exection needs to be single lines. (See attachment) The expected output is also attached Here is the question: This program will have three functions, the main() create() and retrieve(). 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.
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.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images