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

Write a Python program that prompts the user for the number of classes taken and

ID: 3879384 • Letter: W

Question

Write a Python program that prompts the user for the number of classes taken and then for each class, the letter grade received (e.g. B+) and the number of credits (e.g. 3). Once this information is known, the program should calculate and display the GPA, and the values are: A (4.0), A- (3.7), B+ (3.3), B (3.0), B- (2.7), C+ (2.3), C (2.0), C- (1.7), D+ (1.3), D (1.0) and F (0.0). Assumptions: The user will take at least one and no more than seven courses. Each course has a credit value between one and five (inclusive). A grade can be entered in uppercase or lowercase. For example, either A- or a-. All user inputs will be valid.

Your solution should match this output format exactly:

Explanation / Answer

#assign value for creadit
a_ =4
aM_ =3.7
bP_ =3.3
b_ = 3.0
bM_ = 2.7
cP_ = 2.3
c_ = 2.0
cM_ = 1.7
dP_ = 1.3
d_ = 1
f_ = 0


def calculate(c,v):
    if(c=='a' or c=='A'):
        return (v*a_)
    elif(c=='A-' or c=='a-'):
        return (v*3.7)
    elif(c=='B+' or c=='b+'):
        return (v*3.3)
    elif(c=='B' or c=='b'):
        return (v*3)
    elif(c=='B-' or c=='b-'):
        return (v*2.7)
    elif(c=='C+' or c=='c+'):
        return (v*2.3)
    elif(c=='C' or c=='c'):
        return (v*2)
    elif(c=='C-' or c=='c-'):
        return (v*1.7)
    elif(c=='D+' or c=='d+'):
        return (v*1.3)
    elif(c=='D-' or c=='d-'):
        return (v*1)
    elif(c=='f' or c=='F'):
        return 0


klass = input()
sum = 0
course='none'
v = 0
total = 0
for x in range(0,klass):
    print('Enter grade for Course '+str(x+1)+':')
    course = input()
    print('Enter credits for Course '+str(x+1)+':')
    v = input()
    total = total +int(v)
    sum = sum + calculate(course,v)
a = sum/total

format(a, '.2f')
print(a)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote