Advertisement
Guest User

help2.py

a guest
Feb 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def main():
  2.     myfile = open('grades.txt','r')
  3.     total_grade = 0
  4.     counter = 0
  5.    
  6.     print('Here are your grades:')
  7.  
  8.     for line in myfile:
  9.         contents = line.split(",")
  10.         course = contents[0]
  11.         grade = int(contents[1])
  12.         counter += 1
  13.         total_grade += grade
  14.         print("You got a {} in {}".format(grade, course))
  15.        
  16.     print('The average grade score is')
  17.     print(round(total_grade / counter))
  18.    
  19.     myfile.close()
  20.  
  21. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement