# -----------------------------------------------------------------------------
# Name:        grader.py
# Purpose:     Assignment 2: letter grade calculator
#
# Author:      Raymond Cabrera
# Date:        01/19/2016
# -----------------------------------------------------------------------------

"""
Letter grade calculator for a fictional course

Prompt the user for their grades in percent format
Drops the lowest grade if more than three are entered
Calculate the course average and letter grade based on those remaining
"""

grade_list = []

grade = input("Enter your grade: ")

while grade:  # While input exists, append input to grade_list
    grade_list.append(grade)
    grade = input("Enter your grade: ")

# Convert grade_list elements to float-type and round to 10th place
grade_list = [round(float(grade), 1) for grade in grade_list]

# If grade_list is longer than 3 elements, drop min value
if len(grade_list) > 3:
    print("Dropped grade: " + str(min(grade_list)))
    grade_list.remove(min(grade_list))

# Print all grades counted toward average
print("Based on the following grades: ")
for grade in grade_list:
    print(grade)

# Calculate course average with counted grades
grade = round(sum(grade_list) / len(grade_list), 1)
print("Your course average is " + str(grade))

# Print letter grade based on course average
if grade >= 90.0:
    print("Your letter grade in the course is an A")
elif grade >= 80.0:
    print("Your letter grade in the course is a B")
elif grade >= 70.0:
    print("Your letter grade in the course is a C")
elif grade >= 60.0:
    print("Your letter grade in the course is a D")
else:
    print("Your letter grade in the course is an F")
