So I need to make a program that grades 10 students individually, then displays the average grade for all 10 students.
I think this is how the grading should look, but im not sure how to set up a count on the number of times its graded, or how to set up the average function. Help would be most welcome. I am a horrible coder.
score = int(input("Enter a score between 0 and 100: "))
if score >=89:
print("The grade is an A")
elif score>=79:
print("The grade is a B")
elif score>=69:
print("The grade is a C")
elif score>=59:
print("The grade is a D")
else:
print("The grade is a F")
You can try using a counter variable that goes from 0-9 and use a while loop to check and increment that counter value and after each loop calculates the average and keeps doing this till the last value has been entered
Counter = 0
average = 0
while (Counter <= 10):
score = int(input("Enter a score between 0 and 100: "))
if score >= 89:
print("The grade is an A")
elif score >= 79:
print("The grade is a B")
elif score >= 69:
print("The grade is a C")
elif score >= 59:
print("The grade is a D")
else:
print("The grade is a F")
Counter = Counter + 1
average = (score + average)
average = average/Counter
print("Average of all 10 students:",average)
So right now the code is configured specifically for just 10 loops but you can give the user the power to determine this by suggesting a value to end the loop and the while loop will check for this value and when the loop sees the value it exits the loop and gives a value
Also with each loop there is a counter value that keeps increasing and an average value that holds the sum of the values entered and when the loop exits and average is calculated by dividing the sum by the counters and this gives the results
This should do the trick.
total = 0
for i in range(10):
score = int(input("Enter a score between 0 and 100: "))
if score >= 89:
print("The grade is an A")
elif score >= 79:
print("The grade is a B")
elif score >= 69:
print("The grade is a C")
elif score >= 59:
print("The grade is a D")
else:
print("The grade is a F")
total += score
print("Average of all 10 students:", total/10)
In the for loop you get the score of each student and then add it to the total of all students. When the loop ends you divide it with the total number of students so 10.
total score / total number of students total / 10
You can define a function that finds the average score. Store all the scores in a list and then pass the list as an argument in the function
def avg(scores): #assuming scores is the name of the list
avg = sum(scores)/len(scores)
return "Average score is {}".format(avg)
Or
return f'Average score is {avg}' #for python3
Not sure I understand what you mean by number of times it is graded but I think you can include a while loop and a variable that increases by 1 every time it grades.
Related
I'm new to python and have been trying to create a simple grade calculator which tells the user what grade they've achieved based on their final score they've inputted.
def grades():
try:
score = int(input("Please enter your score between 0 and 100:"))
if score >= 90:
print("Grade:A")
elif score >= 80 :
print("Grade:B")
elif score >= 70:
print("Grade:C")
elif score >= 60:
print("Grade:D")
elif score >= 50:
print("Grade:E")
elif score < 50:
print("Grade:F")
except score not in range (0,101) or ValueError:
int(input("Incorrect value. Please enter your score between 0 and 100:"))
However when I try to run the program, it disregards the range and value error and gives it a grade anyway. Is there any way to rectify this, and if possible how could I make the program more efficient. As I said, I'm new to python, so any feedback would be useful.
Just for fun, let's make it a Match Case statement:
Since you only accept integers, we can take and assign score to input with :=, then check if it's valid with str.isnumeric. If that's true then we'll make score an integer := and check if it's between 0 and 100.
We'll change the input statement if they don't put valid input the first time around.
def grades():
text = "Please enter your score between 0 and 100: "
while True:
if ((score := input(text)).isnumeric() and
(score := int(score)) in range(0, 101)):
break
else:
text = "Incorrect value. Please enter your score between 0 and 100: "
match score:
case x if x >= 90 : grade = 'A'
case x if x >= 80 : grade = 'B'
case x if x >= 70 : grade = 'C'
case x if x >= 60 : grade = 'D'
case x if x >= 50 : grade = 'E'
case _ : grade = 'F'
print(f'Grade: {grade}')
Please note that this will only work in Python 3.10 or greater.
Just do this:
def grades():
try:
score = int(input("Please enter your score between 0 and 100:"))
if score > 100:
while True:
int(input("Incorrect value. Please enter your score between 0 and 100:"))
if score <= 100:
pass
else:
break
if score >= 90:
print("Grade:A")
elif score >= 80 :
print("Grade:B")
elif score >= 70:
print("Grade:C")
elif score >= 60:
print("Grade:D")
elif score >= 50:
print("Grade:E")
elif score < 50:
print("Grade:F")
except:
print("Oops. sommthing went wrong")
grades();
I made some corrections to your code. I added some comments to help explain what is going on. Let me know if this solution works for you:
def grades():
while True:
# Start a loop to ask for user input:
score = int(input("Please enter your score between 0 and 100:"))
# If not in range 1, 100, print error message
if score in range(0, 101):
break
print('Incorrect value. Please enter your score between 0 and 100:')
# calculate grade:
if score >= 90:
print("Grade:A")
elif score >= 80:
print("Grade:B")
elif score >= 70:
print("Grade:C")
elif score >= 60:
print("Grade:D")
elif score >= 50:
print("Grade:E")
elif score < 50:
print("Grade:F")
if __name__ == '__main__':
grades()
Simply assert that the input is in the determined range before checking through score ranges. Really, there is no need for a try/except statement.
def grades():
while True:
score = int(input(...))
if 0 <= score <= 100:
break
# Invalid score
# Check score ranges
...
I have made changes to your code, please test to ensure it performs to expectations.
I have added a while True loop, which attempts to validate the score to be between 0 - 100. If a non-integer value is entered it will hit the ValueError exception. This loop will only exit when a number within the range is entered.
The if statements use interval comparators X <= score < Y. You can read more about interval comparators here.
The if statement was also removed out of the try - except to make debugging easier. The idea is to have the least code possible in try - except so that when an exception triggers, it would be caused by the intended code.
Lastly, you don't want to ask for the user input inside the exception as the user might enter something which may cause another exception which will go uncaught.
def grades():
while True:
# Perform basic input validation.
try:
# Gets the user input.
score = int(input("Please enter your score between 0 and 100: "))
# Checks if the number entered is within 0 - 100. Note that range is non-inclusive for the stop. If it is within 0 - 100 break out of the while loop.
if 0 <= score <= 100:
break
# If a non-integer is entered an exception will be thrown.
except ValueError:
print("Input entered is not a valid number")
# Checking of scores using interval comparison
if score >= 90:
print("Grade:A")
elif 80 <= score < 90:
print("Grade:B")
elif 70 <= score < 80:
print("Grade:C")
elif 60 <= score < 70:
print("Grade:D")
elif 50 <= score < 60:
print("Grade:E")
else:
print("Grade:F")
Question: Write a program to continuously asks the user an exam score given as integer percentages in the range 0 to 100. If a value not in the range is input except for -1, print out an error and prompt the user to try again. Calculate the average of all valid grades input along with the total number of grades in each letter-grade category as follows: 90 to 100 is an A, 80 to 89 is a B, 70 to 79 is a C, 60 to 69 is a D, and 0 to 59 is an F. Use a negative score as a sentinel value to indicate the end of the input. (The negative value is used only to end the loop, so do not use it in the calculations.) For example, if the input is.
#Enter in the 4 exam scores
g1=int(input("Enter an exam score between 0 and 100 or -1 to end: "))
g2=int(input("Enter an exam score between 0 and 100 or -1 to end: "))
g3=int(input("Enter an exam score between 0 and 100 or -1 to end: "))
g4=int(input("Enter an exam score between 0 and 100 or -1 to end: "))
total =(g1 + g2 + g3 + g4)
while g1 is range(0,100):
continue
else:
print("Sorry",g1,"is not in the range of 0 and 100 or -1. Try again!")
while g2 is range(0,100):
continue
else:
print("Sorry",g2,"is not in the range of 0 and 100 or -1. Try again!")
while g3 is range(0,100):
continue
else:
print("Sorry",g3,"is not in the range of 0 and 100 or -1. Try again!")
while g4 is range(0,100):
continue
else:
print("Sorry",g4,"is not in the range of 0 and 100 or -1. Try again!")
#calculating Average
def calc_average(total):
return total/4
def determine_letter_grade(grade):
if 90 <= grade <= 100:
1 + TotalA
elif 80 <= grade <= 89:
1 + TotalB
elif 70 <= grade <= 79:
1 + TotalC
elif 60 <= grade <= 69:
1 + TotalD
else:
1 + TotalF
grade=total
average=calc_average
#printing the average of the 4 scores
print("You entered four valid exam scores with an average of: " + str(average))
print("------------------------------------------------------------------------")
print("Grade Distribution:")
print("Number of A's: ",TotalA)
print("Number of B's: ",TotalB)
print("Number of C's: ",TotalC)
print("Number of D's: ",TotalD)
print("Number of F's: ",TotalF)
Sample output that I was given:
Enter an exam score between 0 and 100 or -1 to end: 88.64
Enter an exam score between 0 and 100 or -1 to end: 103
Sorry, 103 is not in the range of 0 and 100 or -1. Try Again!
Enter an exam score between 0 and 100 or -1 to end: 99.10
Enter an exam score between 0 and 100 or -1 to end: 71.52
Enter an exam score between 0 and 100 or -1 to end: 73
Enter an exam score between 0 and 100 or -1 to end: -1
You entered 4 valid exam scores with an average of 83.07.
Grade Distribution
Number of A’s = 1
Number of B’s = 1
Number of C’s = 2
Number of D’s = 0
Number of F’s = 0
Note: This is my first computer science class so I'm sure there is an obvious work around that I am missing but id appreciate any help I can get
Here is my walk-through explanation:
So, the program is supposed to ask the user what score they got until they say they got a score of -1, in which after you give them their results. To loop until they give -1, we can use a while loop:
inp = float(input("Enter an exam score between 0 and 100 or -1 to end: ")) # Get input
grades = []
while inp > -1: # Loop until user gives a score of -1
if inp >= 0 and inp <= 100: # Check if valid grade
grades.append(inp) # Add grade to grades list
inp = float(input("Enter an exam score between 0 and 100 or -1 to end: ")) # Ask again
else:
print("Sorry", inp, "is not in the range of 0 and 100 or -1. Try again!") # Invalid grade
# ANALYSIS OF GRADES
# Format first line of output - the first str(len(grades)) give the amount of grades they entered,
# and the str(sum(grades) / len(grades)) gives the average of the grades list.
print("You entered", str(len(grades)), "valid exam scores with an average of", str(sum(grades) / len(grades)))
print("Grade Distribution:")
print("Number of A's =", str(sum(90 <= g <= 100 for g in grades)) # I am using a very short notation
print("Number of B's =", str(sum(80 <= g <= 89 for g in grades)) # here - this is basically counting
print("Number of C's =", str(sum(70 <= g <= 79 for g in grades)) # the number of grades that are
print("Number of D's =", str(sum(60 <= g <= 69 for g in grades)) # a valid value based on the checks
print("Number of F's =", str(sum(0 <= g <= 59 for g in grades)) # I am making.
Hopefully my comments help you figure out what is happening in my code!
here your problem can be devided into few parts,
get number of exam from user
get the valid input from user for those exam
calculate the average of all exam
calculate the grade distribution
exit if user input is -1
below code is following all these steps
#calculating Average
def calc_average(scores):
return sum(scores)/len(scores)
grade_dist = {
(90, 101):'A',
(80,90):'B',
(70, 80):'C',
(59, 70):'D',
(0,59):'F'
}
def get_grade_freq(scores):
grades = {'A':0, 'B':0, 'C':0, 'D':0, 'F':0}
for score in scores:
for k, v in grade_dist.items():
if score in range(k[0], k[1]):
grades[v]+=1
print("Grade distributions")
for grade, number in grades.items():
print("Number of {}’s = {}".format(grade, number))
def get_scores(n):
scores = []
cond = True
while cond and n>0:
score = int(input("Enter an exam score between 0 and 100 or -1 to end : "))
if score==-1:
cond=False
return -1
if score not in range(0,101):
print("Sorry, {} is not in the range of 0 and 100 or -1. Try Again!".format(score))
if score in range(0,101):
scores.append(score)
n-=1
return scores
def main():
n = int(input('total number of exams ' ))
scores = get_scores(n)
if scores == -1:
exit(-1)
average = calc_average(scores)
print("You entered {} valid exam scores with an average of {}.".format(n, average))
get_grade_freq(scores)
if __name__=='__main__':
main()
Whenever you have multiple instances of similar things to manipulate (scoring ranges, total counts) you must try to use multi-value structures rather than individual variables. Python's lists and dictionaries are designed for collecting multiple entries either as a positional list or as a keyed index (dictionary).
This will make your code more generalized. You'll know you're on the right track when you manipulate concepts rather than instances.
For example:
grading = [(None,101),("A",90),("B",80),("C",70),("D",60),("F",0)]
scores = {"A":0, "B":0, "C":0, "D":0, "F":0}
counts = {"A":0, "B":0, "C":0, "D":0, "F":0}
while True:
input_value = input("Enter an exam score between 0 and 100 or -1 to end: ")
value = int(input_value)
if value == -1: break
score = next((s for s,g in grading if value >= g),None)
if score is None:
print("sorry ",input_value," is not -1 or in range of 0...100")
continue
scores[score] += value
counts[score] += 1
inputCount = sum(counts.values())
average = sum(scores.values())//max(1,inputCount)
print("")
print("You entered", inputCount, "valid exam scores with an average of: ", average)
print("------------------------------------------------------------------------")
print("Grade Distribution:")
for grade,total in counts.items():
print(f"Number of {grade}'s: ",total)
The grading list contains pairs of score letter and minimum value (in tuples). such a structure will allow you to convert the grade values in to score letters by finding the first entry that has a value lower or equal to the input value and use the corresponding letter.
The same list is used to validate the input value by strategically placing a None value after 100 and no value below zero. The next() function will perform the search for you and return None when no valid entry is present.
Your main program loop needs to continue until the input value is -1 but it needs to go through the input at least onces (typical of a repeat-until structure but there is only a while in Python). So the while statement will loop forever (i.e. while True) and will need to be arbitrarily broken when the exit condition is met.
To accumulate the scores, a dictionary (scores) is better suited than a list because a dictionary will allow you to access instances using a key (the score letter). This allows you to keep track of multiple scores in a single variable. The same goes for counting how many of each score were entered.
To get the average at the end, you simply need to sum up the values scores of the scores dictionary and divide by the count of of scores you added to the counts dictionary.
Finally to print the summary of score counts, you can leverage the dictionary structure again and only write one generalized printing line for all the score letters and totals.
This may work for you:
scores = {
"A": 0,
"B": 0,
"C": 0,
"D": 0,
"F": 0,
}
total = 0
count = 0
input_value = 0
while (input_value != -1) and (count < 4):
input_value = int(input("Enter an exam score between 0 and 100 or -1 to end: "))
if 0 <= input_value <= 100:
total += input_value
count += 1
if input_value >= 90:
scores["A"] += 1
elif input_value >= 80:
scores["B"] += 1
elif input_value >= 70:
scores["C"] += 1
elif input_value >= 60:
scores["D"] += 1
else:
scores["F"] += 1
else:
print("Sorry", input_value, "is not in the range of 0 and 100 or -1. Try again!")
print("You entered {} valid exam scores with an average of: {}".format(count, total / count))
print("------------------------------------------------------------------------")
print("Grade Distribution:")
print("Number of A's: ", scores['A'])
print("Number of B's: ", scores['B'])
print("Number of C's: ", scores['C'])
print("Number of D's: ", scores['D'])
print("Number of F's: ", scores['F'])
I have been struggling with this code for a couple hours and am not seeing much in previous questions that relates to it. I've gone down the rabbit hole trying to make it work so I think it's pretty inefficient at this point as well as isn't outputting in the manner I'd like.
I am trying to get user input in the form of multiple grade entries, evaluate them based on grading criteria and then output the students grade in letter form
Any advice on getting it to output correctly or on any better coding techniques would be greatly appreciated. Thanks ahead of time from a novice coder.
Here is my code:
"""10.1 - write a program that reads a list of scores and then
assigns letter grades based on the criteria:
A if score is >= best - 10
B if score is >= best - 20
C if score is >= best - 30
D if score is >= best - 40
F otherwise
"""
grades_input = input("Enter Students scores seperated by a space: ") #get user input of student's grades
grades_list = grades_input.split() #split user input into a list
grades_list_valid = [ int(x) for x in grades_list ] #convert items into integers
number_of_students = []
for i in range(len(grades_list_valid)):
number_of_students.append(i)
for grade in grades_list_valid: #create criteria to assign each letter grade
best_score = max(grades_list_valid) #get the highest grade
if grade >= best_score - 10:
print("Student {}".format(number_of_students[i]), "score is {}".format(grades_list_valid[i]), "and grade is A")
elif grade >= best_score - 20:
print("Student {}".format(number_of_students[i]), "score is {}".format(grades_list_valid[i]), "and grade is B")
elif grade >= best_score - 30:
print("Student {}".format(number_of_students[i]), "score is {}".format(grades_list_valid[i]), "and grade is C")
elif grade >= best_score - 40:
print("Student {}".format(number_of_students[i]), "score is {}".format(grades_list_valid[i]), "and grade is D")
else:
print("Student {}".format(number_of_students[i]), "score is {}".format(grades_list_valid[i]), "and grade is F")
and here is the output:
Enter Students scores seperated by a space: 40 55 70 58
Student 3 score is 58 and grade is C
Student 3 score is 58 and grade is B
Student 3 score is 58 and grade is A
Student 3 score is 58 and grade is B
The desired output is:
Student 0 score is 40 and grade is C
Student 1 score is 55 and grade is B
Student 2 score is 70 and grade is A
Student 3 score is 58 and grade is B
Its because your first loop to get i is completing before you make use of i, then i is already 3 when you loop through to print the results. Instead you should get the index in your second loop like this:
grades_input = input("Enter Students scores seperated by a space: ") #get user input of student's grades
grades_list = grades_input.split() #split user input into a list
grades_list_valid = [ int(x) for x in grades_list ] #convert items into integers
best_score = max(grades_list_valid)
for i, grade in enumerate(grades_list_valid):
letter_grade = "F"
if grade >= best_score - 10:
letter_grade = "A"
elif grade >= best_score - 20:
letter_grade = "B"
elif grade >= best_score - 30:
letter_grade = "C"
elif grade >= best_score - 40:
letter_grade = "D"
else:
letter_grade = "F"
print("Student {} score is {} and grade is {}".format(i, grade, letter_grade))
and then eliminate the first loop.
After looking again at the question i also noticed you were grabbing the "best score" from the same list every time, which would make each student have the same score. Im guessing you just want to grab the score for each student. I updated my answer to work for that - not sure if it was your desired behaviour.
Edit: looked at it again and realized what you were doing with best score, fixed my answer here's the results when i run it:
Enter Students scores seperated by a space: "70 80 93 77 31"
Student 0 score is 70 and grade is C
Student 1 score is 80 and grade is B
Student 2 score is 93 and grade is A
Student 3 score is 77 and grade is B
Student 4 score is 31 and grade is F
grades_input = input("Enter Students scores seperated by a space: ") #get user input of student's grades
grades_list = grades_input.split() #split user input into a list
grades_list_valid = [ int(x) for x in grades_list ] #convert items into integers
number_of_students = []
for i in range(len(grades_list_valid)):
number_of_students.append(i)
i=0
for grade in grades_list_valid: #create criteria to assign each letter grade
best_score = max(grades_list_valid) #get the highest grade
print(i)
if grade >= best_score - 10:
print("Student {}".format(number_of_students[i]), "score is {}".format(grades_list_valid[i]), "and grade is A")
elif grade >= best_score - 20:
print("Student {}".format(number_of_students[i]), "score is {}".format(grades_list_valid[i]), "and grade is B")
elif grade >= best_score - 30:
print("Student {}".format(number_of_students[i]), "score is {}".format(grades_list_valid[i]), "and grade is C")
elif grade >= best_score - 40:
print("Student {}".format(number_of_students[i]), "score is {}".format(grades_list_valid[i]), "and grade is D")
else:
print("Student {}".format(number_of_students[i]), "score is {}".format(grades_list_valid[i]), "and grade is F")
i+=1
this the correct way,in your code i=3 which is why you are getting the same answer for each student
As Quinn said, your top loop iterates over i, which finishes at i = 3. Future references to i will yield 3.
Some things I noticed:
1) What you can do is check their grade at the same time as you loop through.
2) Additionally, you don't need to find the maximum each loop, you can get it once outside the loop and then reference it inside.
3) Finally, it looks quite ugly when you have all of these print statements, it makes it much nicer to read if you assign the grade in the if statements and then print once with the found grade, like so:
best_score = max(grade_list_valid)
for i in range(len(grades_list_valid)):
curr_score = grades_list_valid[i]
if(curr_score >= best_score - 10):
grade = "A"
...
print("Student {} score is {} and grade is {}".format(i, curr_score, grade))
There are some further small optimisations you can make as well. For example, the list comprehension you have:
[ int(x) for x in grades_list ]
Is the classic case for a map:
map(int, grades_list)
I'm writing a python program that drops the lowest of four test scores. The program first prompts the user to enter their first four test scores, then the program should drop the lowest test score and take the average of the remaining three test scores. The program should then print the final letter grade. This is what I have so far and I keep receiving an error when dropping the lowest score.
#Enter four test scores as percentages (%)
test1 = int(input("Enter grade 1: 90"))
test2 = int(input("Enter grade 2: 80"))
test3 = int(input("Enter grade 2: 70)")
test4 = int(input("Enter grade 2: 80)")
#Drop lowest test score
print("The average, with the lowest score dropped" )
total =(test1 + test2 + test3)
#Calculate average
def calc_average(total):
return total /3
#Grade scale
def determine_score(grade):
if score >= 90:
grade = "A"
elif score >= 80:
grade = "B"
elif score >=70:
grade = "C"
elif score >= 60:
grade = "D"
else:
grade = "F"
#Calculate final letter grade
print("The final grade is")
main()
I tried to write a program with the things that I understood from you.
Here is the explanation:
Taking four grades from user.
Dropping the lowest one.
Taking average.
Giving a letter grade according to the average.
Here is the code:
test1 = int(input("Enter grade 1: "))
test2 = int(input("Enter grade 2: "))
test3 = int(input("Enter grade 3: "))
test4 = int(input("Enter grade 4: "))
x = min(test1,test2,test3,test4)
total = float(test1 + test2 + test3 + test4 - x)
avg = total / 3
print("Your average is " + str(avg))
def determine_letter(grade):
letter =""
if grade >= 90:
letter = "A"
elif grade >= 80:
letter = "B"
elif grade >= 70:
letter = "C"
elif grade >= 60:
letter = "D"
else:
letter = "F"
print("The final letter grade is " + letter)
determine_letter(avg)
I could use some help solving an error. This is my code that takes in multiple inputs, and outputs ( the amount of inputs, the amount of students who miss the test, the students who got a grade higher then 80, the average of those who took the test, and the average of the entire class including those who missed.
#number of students who miss, and get a highscore
num_miss = 0
num_high = 0
total = 0
count = 0
#The minimum and maximum values
min_score = 100.00
max_score = 0.0
score = int(input("Enter a Score(-1 to quit): "))
#The loop to test score inputs, and the students who missed or got a high score
while score >-1:
if score >= 80:
num_high += 1
elif score == 0:
num_miss += 1
if score < min_score:
min_score = score
if score > max_score:
max_score = score
score = int(input("Enter a Score(-1 to quit): "))
# an incriment to count the total for average, and the amount of students that took the exam
total += score
count += 1
students = count
#formulas for creating the averages
average = total / count
average2 = total / (count + -num_miss)
#prints grade report with a dashed line under it
print("Grade Report")
print("-" * 38)
if count >= 0:
print("Total number of students in the class: {}".format(students))
print("Number of students who missed the exam: {}".format(num_miss))
print("Number of students who took the exam: {}".format(count - num_miss))
print("Number of students who scored high: {}".format(num_high))
print("Average of all students in the class: {0:.2f}".format(average))
print("Average of students taking the exam: {0:.2f}".format(average2))
This is the problem: by inputing all these values: 65, 98, 45, 76, 87, 94, 43, 0, 89, 80, 79, 0, 100, 55, 75, 0, 77, -1 to end
This is what my professor gets for an output
Grade Report
1. Total number of students in the class: 17
2.Number of students who missed the exam: 3
3.Number of students who took the exam: 14
4.Numberof students who scored high: 6
5.Average of all students in the class:62.5
6.Average of students taking the exam: 75.9
This is what i get for an output
Grade Report
1.Total number of students in the class: 17
2.Number of students who missed the exam: 3
3.Number of students who took the exam: 14
4.Number of students who scored high: 6
5.Average of all students in the class: 58.64
6.Average of all students taking the exam: 71.21
How do I fix my averages so that they are the same as my professors?
You're including the last "-1" as part of your data set.
Also, Why are you doing this:
average2=total/(count+-numMiss)
as opposed to this:
average2=total/(count-numMiss)
The first problem is that you include the -1. You should do
while True:
...
score=int(input("Enter a Score(-1 to quit): "))
if score == -1:
break
...
You only need this line once:
score = int(input("Enter a Score(-1 to quit): "))
And it should be inside the loop.
The code should look something like this:
while True:
score = int(input("Enter a Score(-1 to quit): "))
if score <= -1:
break
Also, this line can move outside the loop:
students = count