Hello Trask, I have been working on the first program. I got the files to read and print out the grades and averages, but when I write these files to the other txt file, all that I get is:
10.0
10.0
10.0
10.0
10.0
10.0
10.0
10.0
10.0
10.0
I know it is something simple. I am just not seeing it. Here is my code:
Grades = [ ]
filename = raw_input("Enter the filename with 10 grades to be averaged: ")
my_file_object = open (filename, "r")
for a in range (10):
temp_string = my_file_object.readline()
Grades = Grades + [ float (temp_string)]
my_file_object.close()
for a in range (len(Grades)):
print "Grade", str (a + 1) + ":", Grades [a]
total = 0
for a in range (len(Grades)):
total = total + Grades[a]
average = total/float (len(Grades))
print "The average grade was: ", round(average,2)
print ""
print "Okay, we are assuming that you have created a file named
'grade_file_2.txt' that is empty, yes?"
print ""
fname= raw_input("Please enter 'grade_file_2.txt' to write to new file: ")
grades_file_2 = open("grade_file_2.txt", "w")
for count in range (len(Grades)):
grades_file_2.write(str("%.2f"% (len(Grades))) + "\n")
grades_file_2.close()
print ""
print "Nice Job. your file is done."
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
I am including the files. Let me know if you see anything goofy.
Tom Mundahl
tm_week11_problem1.py
Description: Binary data
10.00 10.00 10.00 10.00 10.00 10.00 10.00 10.00 10.00 10.00
90.50 88.25 98.95 94.90 95.44 96.84 97.99 98.25 99.55 96.88
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
