title: Printing statement does not provide me with accurate numbers
body: <p>Ok here's the problem, the code works, but the numbers dont add up right, so im missing something somewhere. My brain is absolutely dead from working on this for three days straight so i need another set of eyes. Basically this is a grading calculator that takes input from a .txt file and sends output to a .txt file. I am dropping the lowest quiz score. I also need a little help with the outfile.write(outstring) formatting, it's all over the place right now and i need it to look exactly like the output file. Im leaving in some diagnostic print statements but essentially this is what the code looks like right now:</p>
  
  <pre><code>infilename = input("Please enter file name: ")
  outfilename = input("Please enter output file name: ")
  
  infile = open(infilename,"r")
  outfile = open(outfilename, "w")
  
  quiz_sum = 0
  low_quiz = 1000
  prog_sum = 0
  
  nameline = infile.readline()
  outfile.write(nameline)
  print(nameline)
  while nameline != "":
      quiz_line = infile.readline()
      prog_line = infile.readline()
      exam_line = infile.readline()
      quiz_list=quiz_line.split()
      quiz_sum = 0
      prog_sum = 0
      low_quiz = 1000
      for quiz_score in quiz_list:
          quiz_float = float(quiz_score)
          quiz_sum += quiz_float
          if quiz_float &lt; low_quiz:
              low_quiz = quiz_float
      if len(quiz_list) &gt; 1:
          quiz_avg = ((quiz_sum-low_quiz)/(len(quiz_list)-1))*10
      else:
          quiz_avg = quiz_sum*10
      print("QUIZ AVERAGE", quiz_avg)
      prog_list = prog_line.split()
      for prog_score in prog_list:
          prog_float = float(prog_score)
          prog_sum += prog_float
      if len(prog_list) &gt; 1:
          prog_avg = ((prog_sum) / len(prog_list))*10
      else:
          prog_avg = prog_sum*10
      print("PROGRAM AVERAGE", prog_avg)
      exam_list = exam_line.split()
      for exam_score in exam_list:
          exam_float = float(exam_score)
          #exam_sum += exam_float
      exam1 = float(exam_list[0])
      exam2 = float(exam_list[1])
      exam3 = float(exam_list[2])
      exam_avg = (exam1*.20)+(exam2*.20)+(exam3*.25)
      print("EXAMs" , exam1,exam2,exam3)
      average = ((quiz_avg*.15)+(prog_avg*.20)+(exam_avg))
      if 90 &lt;= average &lt;= 100:
          final_grade = "A"
      if 80 &lt;= average &lt; 90:
          final_grade = "B"
      if 70 &lt;= average &lt; 80:
          final_grade = "C"
      if 60 &lt;= average &lt; 70:
          final_grade = "D"
      if 0 &lt;= average &lt; 60:
          final_grade = "F"
      print("TOTAL AVERAGE",average)
      outstring =("%-20s %3.1f   %s" %(nameline,average,final_grade))
      print(outstring)
      outfile.write(outstring)
      nameline = infile.readline()
      outstring = ("%-20s***" % (nameline))
  
  infile.close()
  outfile.close()
  </code></pre>
  
  <p>Here is what the input will look like (1st row of numbers are quizzes, second is program projects, and third are exams [exam1,2,3 respectively]):</p>
  
  <pre><code>Babbage, Charles
  10.0   9.5    8.0  9.0
   9.5  10.0    9.0
  85.0  92.0   81.0
  Turing, Alan
  1.0   8.0    6.0
  10.0  10.0    9.0   9.5
  90.0  92.0   88.5
  Hopper, Grace
  10.0  5.0    8.0
  10.0  10.0    9.0   9.5
  90.0  92.0   88.0
  Van Rossum, Guido
   7.5   8.5
   7.5   6.0    6.0   9.0
  68.0  81.0   70.0
  Backus, John
   9.5   3   10.0   8.0   9.5  10.0
   7.5   8.5    6.0   9.0  10.0
  99.0  93.0  44.0
  Crawley, Bryan
   6.0
   7.5
  70.0  60.0   55.5
  </code></pre>
  
  <p>And finally this is what is supposed to be the formatting of the output:</p>
  
  <pre><code>Babbage, Charles      89.4   B
  Turing, Alan          91.3   A
  Hopper, Grace         92.7   A
  Van Rossum, Guido     75.5   C
  Backus, John          94.4   A
  Crawley, Bryan        63.9   D
  </code></pre>
  
  <p>tl;dr - I need to get the right numbers for the averages for this program to work. I also need help with the format for how the program writes to the file at the end of the loop. Thanks guys.</p>
  
  <p>EDIT - </p>
  
  <p>Updating post to show what happens when i run the program:
      Please enter file name: scores.txt
      Please enter output file name: results.txt
      Babbage, Charles</p>
  
  <pre><code>QUIZ AVERAGE 95.0
  PROGRAM AVERAGE 95.0
  EXAMs 85.0 92.0 81.0
  TOTAL AVERAGE 88.9
  Babbage, Charles
      88.9   B
  QUIZ AVERAGE 70.0
  PROGRAM AVERAGE 96.25
  EXAMs 90.0 92.0 88.5
  TOTAL AVERAGE 88.275
  Turing, Alan
          88.3   B
  QUIZ AVERAGE 90.0
  PROGRAM AVERAGE 96.25
  EXAMs 90.0 92.0 88.0
  TOTAL AVERAGE 91.15
  Hopper, Grace
         91.2   A
  QUIZ AVERAGE 85.0
  PROGRAM AVERAGE 71.25
  EXAMs 68.0 81.0 70.0
  TOTAL AVERAGE 74.3
  Van Rossum, Guido
     74.3   C
  QUIZ AVERAGE 94.0
  PROGRAM AVERAGE 82.0
  EXAMs 99.0 93.0 44.0
  TOTAL AVERAGE 79.9
  Backus, John
          79.9   C
  QUIZ AVERAGE 60.0
  PROGRAM AVERAGE 75.0
  EXAMs 70.0 60.0 55.5
  TOTAL AVERAGE 63.875
  Crawley, Bryan
        63.9   D
  </code></pre>
  
  <p>And this is what is in the "results.txt" file:</p>
  
  <pre><code>Babbage, Charles
  Babbage, Charles
      88.9   BTuring, Alan
          88.3   BHopper, Grace
         91.2   AVan Rossum, Guido
     74.3   CBackus, John
          79.9   CCrawley, Bryan
        63.9   D
  </code></pre>