Python Quiz Scores Sorting

Quiz Scores Sorting

# Read in a bunch of quiz scores (out of 10)
# compute the mean, and the letter grade of the mean
# then Print out the mean grade and the letter grade.

# This function computes the mean of a list of numbers.
# From page 9 on the python hand out.
def mean(number_list):
    if len(number_list) < 1:
	return 0
    sum = 0.0
    for x in number_list:
	sum = sum + x
    return sum/len(number_list)

# This function reads in a list of numbers length size, with values
# between min_value and max_value
def read_list_between(size,min_value,max_value):
    return_list=[]
    input_string="Please input a number between "+str(min_value)+" and "
    input_string= input_string + str(max_value) +" : "
    while len(return_list) < size:
	number = input(input_string)
	if number < min_value or number > max_value:
	    print number, "is not between",min_value,"and","max_value"
	else:
	    return_list.append(number)
    return return_list


# A function to return a letter grade given a number between 0 and 1
def letter_grade(grade):
    if grade >= .9:
	return "A"
    elif grade >= .8:
	return "B"
    elif grade >= .7:
	return "C"
    elif grade >= .6:
	return "D"
    else:
	return "F"


# Main program

num_quizzes = input("Please enter the number of quiz scores: ")
quiz_grades = read_list_between(num_quizzes,0,10)
quiz_mean = mean(quiz_grades)
letter=letter_grade(quiz_mean/10)
print "The mean of the quizzes is", quiz_mean, "for a letter grade of", letter