# letter_grade_converter_function.py
# This program accepts an exam score as input and prints out
# the corresponding grade using a function.
# 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: "))
def letter_grade_converter(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.
return f"Your letter grade is {letter_grade}."
print(letter_grade_converter(score))
main()
Photo by Kimberly Farmer on Unsplash
Top comments (0)