DEV Community

Cover image for Letter Grade Converter
Scott Gordon
Scott Gordon

Posted on

Letter Grade Converter

# letter_grade_converter.py
#   This program accepts an exam score as input and prints out
#   the corresponding grade.
# by: Scott Gordon

def main():
    # Write welcome message.
    print("***** Welcome to The Letter Grade Calculator *****")

    # Get input from user and assign it to score variable.
    score = int(input("Enter your exam score: "))

    # Use branching control statements to associate the score
    #       with the letter grade.
    letter_grade = ""
    if score < 60:
        letter_grade = "F"
    elif score < 70:
        letter_grade = "D"
    elif score < 80:
        letter_grade = "C"
    elif score < 90:
        letter_grade = "B"
    elif score < 100:
        letter_grade = "A"

    # Print out the corresponding grade.
    print(f"Your letter grade is {letter_grade}.")


main()
Enter fullscreen mode Exit fullscreen mode

Top comments (0)