47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
gradetable = {
|
|
"90-100": "A",
|
|
"80-89": "B",
|
|
"70-79": "C",
|
|
"60-69": "D",
|
|
"0-59": "F"
|
|
}
|
|
|
|
def main():
|
|
usercontinue = 'yes'
|
|
while usercontinue == 'yes':
|
|
try:
|
|
score = int(input("What was the exam score?: "))
|
|
|
|
if 90 <= score <= 100:
|
|
grade = gradetable["90-100"]
|
|
elif 80 <= score <= 89:
|
|
grade = gradetable["80-89"]
|
|
elif 70 <= score <= 79:
|
|
grade = gradetable["70-79"]
|
|
elif 60 <= score <= 69:
|
|
grade = gradetable["60-69"]
|
|
elif 0 <= score <= 59:
|
|
grade = gradetable["0-59"]
|
|
else:
|
|
grade = 'invalid score'
|
|
|
|
print(f"The letter score of score of the exam was {grade}")
|
|
|
|
except ValueError:
|
|
print("Invalid input. Please enter a number.")
|
|
|
|
|
|
usercontinueprompt = input("Would you like to determine the letter grade of another score? (yes/no): ")
|
|
usercontinueprompt = usercontinueprompt.lower() #Convert to lowercase once
|
|
|
|
if usercontinueprompt == 'yes': #Corrected to assignment
|
|
usercontinue = 'yes'
|
|
elif usercontinueprompt == 'no':
|
|
print("Thanks, have a great day!")
|
|
usercontinue = 'no' # Corrected typo and assignment
|
|
else:
|
|
print("That wasn't a valid selection. Try again")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |