Answer to Question #183756 in Python for raj

Question #183756

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

Sample Run 1

Enter your Letter Grade: B
Is it weighted? (1 = yes, 0 = no) 1
Your GPA score is : 4

Sample Run 2

Enter your Letter Grade: B
Is it weighted? (1= yes, 0= no) 0
Your GPA score is: 3

Sample Run 3

Enter your Letter Grade: a
Is it weighted?(1 = yes, 0 = no) 0
Your GPA score is : 4
1
Expert's answer
2021-04-20T19:44:35-0400
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])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS