Adjust the code you wrote for the last problem to allow for weighted classes. Add a parameter weighted (1 = yes, 0 = no) and then return the correct number for the GPA. Weighted classes get one extra point on the GPA value.
Input: Letter GradeExpected output: Non-weighted GPA valueExpected output: Weighted GPA valueA45B34C23D12F01Anything elseInvalidInvalid
Enter your Letter Grade: B
Is it weighted? (1 = yes, 0 = no) 1
Your GPA score is : 4
Enter your Letter Grade: B
Is it weighted? (1= yes, 0= no) 0
Your GPA score is: 3
Enter your Letter Grade: a
Is it weighted?(1 = yes, 0 = no) 0
Your GPA score is : 4
gpa = {'a': {'0':'4', '1':'5'},'b': {'0':'3', '1':'4'},'c': {'0':'2', '1':'3'},'d': {'0':'1', '1':'2'},'f': {'0':'0', '1':'1'}}
grade = input("Enter your Letter Grade: ").lower()
weight = input("Is it weighted? (1 = yes, 0 = no) ")
print("Your GPA score is : " + gpa[grade][weight])
Comments
Leave a comment