Respuesta :
Answer:
This program is written in Python Programming Language
Program doesn't make use of comments (See Explanation Section for detailed explanation)
letterg = ['A','B','C','D','F']
inp = input("Enter a Letter Grade: ")
for i in range(len(letterg)):
if inp.upper() == letterg[i]:
print('The numeric value for grade ', inp, ' is ',4 - i)
break;
else:
print(inp, "is an invalid grade")
Explanation:
This line initializes all letter grade from A to F
letterg = ['A','B','C','D','F']
This line prompts user for letter grade
inp = input("Enter a Letter Grade: ")
This line iterates through the initialized letter grades
for i in range(len(letterg)):
This line checks if the user input is present in the initialized letter grades (it also takes care of lowercase letters)
if inp.upper() == letterg[i]:
This line is executed if tge about condition is true; the line calculates the number grade and prints it
print('The numeric value for grade ', inp, ' is ',4 - i)
This line terminates the iteration
break;
If the condition above is not true
else:
This line is executed
print(inp, "is an invalid grade")