Question

In: Computer Science

using JUPYTER notebook: 9.1 (Class Average: Writing Grades to a Plain Text File) Figure 3.2 presented...

using JUPYTER notebook:

9.1 (Class Average: Writing Grades to a Plain Text File) Figure 3.2 presented a classaverage script in which you could enter any number of grades followed by a sentinel value, then calculate the class average. Another approach would be to read the grades from a file. In an IPython session, write code that enables you to store any number of grades into a grades.txt plain text file.

In an IPython session, write code that reads the grades from the grades.txt file you created in the previous exercise. Display the individual grades and their total, count and average.

Solutions

Expert Solution

Program Code Screenshot:

Sample output:

The screenshots are attached below for reference.

Please follow them for proper indentation and output.

Program to copy:

f=open("grades.txt",'r')#open file in read mode
l=list(f.readlines())
print("The grades are:")
for i in range(len(l)):
l[i]=int(l[i][:-1])#convert grade to int type and remove new line characters
print(l[i])#print the grades

print("The total is:",sum(l))#print the total grades
print("The count is: ",len(l))#print number of grades
print("The average is: ",sum(l)/len(l))

Note:

Please let me know in case of any help needed in the comments section.

Plese upvote my answer. Thank you.


Related Solutions

Please solve using jupyter notebook . 10.10- (Invoice Class) Create a class called Invoice that a...
Please solve using jupyter notebook . 10.10- (Invoice Class) Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as data attributes—a part number (a string), a part description (a string), a quantity of the item being purchased (an int) and a price per item (a Decimal). Your class should have an __init__ method that initializes the four data attributes....
please solve using jupyter notebook . 10.9- (Square Class) Write a class that implements a Square...
please solve using jupyter notebook . 10.9- (Square Class) Write a class that implements a Square shape. The class should contain a side property. Provide an __init__ method that takes the side length as an argument. Also, provide the following read-only properties: a) perimeter returns 4 × side. b) area returns side × side. c) diagonal returns the square root of the expression (2 × side2). The perimeter, area and diagonal should not have corresponding data attributes; rather, they should...
Python class Select a free ebook on gutenberg . org and download the plain text file...
Python class Select a free ebook on gutenberg . org and download the plain text file (utf8). the ebook is (The Devil's Dictionary by Ambrose Bierce) Write a program that does the following: Read in your ebook (any book, any language) Break the book into words (look at .split() for strings) Make a dictionary of all words and how often they occur: for instance if the word'the'happened 2000 time and the word'a' happened 1940 times word_dict= {'the' : 2000, 'a'...
Python class Select a free ebook and download the plain text file (utf8). Write a program...
Python class Select a free ebook and download the plain text file (utf8). Write a program that does the following: Read in your ebook (any book, any language) Break the book into words (look at .split() for strings) Make a dictionary of all words and how often they occur: for instance if the word'the' happened 2000 time and the word'a' happened 1940 times word_dict= {'the' : 2000, 'a' :1940} Print the dictionary of word frequencies to a file (freqs.txt) with...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT