Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Based in Python 3.5.1. Write a gradebook program that lets a teacher keep track

ID: 3681970 • Letter: B

Question

Based in Python 3.5.1.

Write a gradebook program that lets a teacher keep track of test averages for his or her students. Your program shoudl begin by asking the teacher for a number of students in their class as well as the total # of tests that will be given to the class. Validate this information to ensure that the numbers entered are positive.

Next, prompt the teacher to enter in scores for each student. Ensure that the values entered are positive - if they aren't you will need to re-prompt them. Hint: you may need to use nested loops here! A "while" loop can be placed inside of a "for" loop, if necessary.

Once your program has collected all test scores for a student it should display that student's average and move onto the next student. When all students have been calculated the program should compute the overall average score for the entire class.

Here's a sample running of your program:

Some hints:

Begin by constructing a "for" loop to iterate over all students in the class

Once you're inside of this "for" loop you will probably need another loop to handle inputting the scores for a particular student.

Big hint: Try to get your program to work first without any data validation. You can add this in later once you figure out the general structure of the program.

Remember the difference between "for" and "while" loops! "for" loops are used when you want to iterate over a know # of items, and "while" loops can be used to keep the user "caught" indefinately until they fulfill a particular condition. You will probably need to use a combination of these loops to solve this problem.

Explanation / Answer

Please find the required program and output :

students = int(input("How many students are in your class?"))
while (students <= 0):
print "Invalid # of students, try again."
students = int(input("How many students are in your class?"))

tests = int(input("How many tests in this class?"))
while (tests <= 0):
print "Invalid # of tests, try again"
tests = int(input("How many tests in this class?"))
  
print "Here we go!"

average = 0
for i in range(1,students+1):
print '**** Student #%d****' % (i)
total = 0
for t in range(1,tests+1):
s = int(input("Enter score for test #%d:" %(t)))
while (s < 0):
print "Invalid score, try again"
s = int(input("Enter score for test #%d:" %(t)))
total = total + s
average = total/tests
print "Average score for student #%d is %f" %(i,average)
avg = average / students
print "Average score for all students is: %f" %(avg)

--------------------------------------------------------------------------------

How many students are in your class?

3

How many tests in this class?2                                                                                                                                                                                

Here we go!                                                                                                                                                                                                   

**** Student #1****                                                                                                                                                                                           

Enter score for test #1:44                                                                                                                                                                                    

Enter score for test #2:46                                                                                                                                                                                    

Average score for student #1 is 45.000000                                                                                                                                                                     

**** Student #2****                                                                                                                                                                                           

Enter score for test #1:22                                                                                                                                                                                    

Enter score for test #2:77                                                                                                                                                                                    

Average score for student #2 is 49.000000                                                                                                                                                                     

**** Student #3****                                                                                                                                                                                           

Enter score for test #1:99                                                                                                                                                                                    

Enter score for test #2:100                                                                                                                                                                                   

Average score for student #3 is 99.000000                                                                                                                                                                     

Average score for all students is: 33.000000

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote