Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. num_students= int(input("How many students are in the class? - "))
  2.  
  3.  
  4. while num_students <= 0:
  5. print("Sorry, that number of students is invalid.")
  6. num_students= int(input("How many students are in the class? - "))
  7.  
  8. num_tests= int(input("How many tests were in this class? - "))
  9.  
  10. while num_tests <= 0:
  11. print("Sorry, not valid number of tests.")
  12. num_tests= int(input("How many tests were in this class? - "))
  13.  
  14. student_score= 0
  15. total_score=0
  16.  
  17.  
  18. for student_count in range(num_students):
  19. print("Student %2d: " % (student_count+1))
  20.  
  21. for test_count in range(num_tests):
  22. grade= float(input("Score on test%2d " %(test_count+1)))
  23.  
  24.  
  25. while grade <=0:
  26. print("Sorry, invalid input for test grade!")
  27. grade= float(input("Score on test%2d " %(test_count+1)))
  28.  
  29. student_score+= grade
  30. total_score+= grade
  31.  
  32. student_avg= student_score/num_tests
  33. print("Average score for the student %2d = %5.2f"%(student_count+1,student_avg))
  34.  
  35. total_avg_score= total_score/(num_tests*num_students)
  36. print(total_score)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement