Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

FOR PYTHON: Write a function letter2number () that takes a string representing a

ID: 642928 • Letter: F

Question

FOR PYTHON: Write a function letter2number() that takes a string representing a letter grade as a parameter and returns the grade point associated with that grade. The grade letter will be one of A, B, C, D, or F (upper- or lowercase). It may include a plus or minus after the letter. An A corresponds to a grade point of 4, a B to 3, a C to 2, a D to 1, and an F to 0. A plus increases the base grade point by 0.3 and a minus decreases it by 0.3. There is no such thing as an A+ or an F-. If the user provides a string as an argument that doesn't correspond to a valid grade, the function returns the string 'unknown grade'. You MUST use a dictionary for this problem. Any solution that does not involve a dictionary will not earn full credit. The following shows the function as used on several different arguments:

FOR PYTHON: Write a function letter2number() that takes a string representing a letter grade as a parameter and returns the grade point associated with that grade. The grade letter will be one of A, B, C, D, or F (upper- or lowercase). It may include a plus or minus after the letter. An A corresponds to a grade point of 4, a B to 3, a C to 2, a D to 1, and an F to 0. A plus increases the base grade point by 0.3 and a minus decreases it by 0.3. There is no such thing as an A+ or an F-. If the user provides a string as an argument that doesn't correspond to a valid grade, the function returns the string 'unknown grade'. You MUST use a dictionary for this problem. Any solution that does not involve a dictionary will not earn full credit. The following shows the function as used on several different arguments:

Explanation / Answer

Hope this may helps you...

import random
import time

def get_letter_grade(percentage):
if percentage >= 95:
letter_grade = "A"
elif percentage >= 92:
letter_grade = "A-"
elif percentage >= 89:
letter_grade = "B+"
elif percentage >= 86:
letter_grade = "B"
elif percentage >= 83:
letter_grade = "B-"
elif percentage >= 80:
letter_grade = "C+"
elif percentage >= 77:
letter_grade = "C"
elif percentage >= 74:
letter_grade = "C-"
elif percentage >= 71:
letter_grade = "D+"
elif percentage >= 68:
letter_grade = "D"
elif percentage >= 65:
letter_grade = "D-"
else:
percentage <= 65
letter_grade = "F"

def menu_choice():
print('1: Enter grade in percentage (0-100)')
print('2: Get letter grade from percentage grade')
print('3: Calculate letter grade with extra credit')
print('4: Calculate exctra credit needed to boost letter grade')
print('0: Exit')
print()
return input ("Please make your choice:")

loop = 1
choice = 0
while loop == 1:
choice = menu_choice()
if choice == 1:
print("Enter percentage grade(0-100)?")
elif choice ==2:
print(letter_grade)
elif choice ==3:
print(percentage + (input))
elif choice ==4:
print()
elif choice ==0:
loop = 0