Question

2-3-B for GPA You previously calculated a GPA using a loop; in this assignment youll use a for loop A GPA, or Grade Point Average, is calculated by summing the grade points earned in a students courses and then dividing by the total units The grade-points for an individual course are calculated by multiplying the units for that course by the appropriate factor depending upon the grade received A receives 4 grade-points B receives 3 grade-points C receives 2 grade-points D receives 1 grade-point F receives 0 grade-point Your program will have a for loop to calculate multiple GPAs and a for loop to collect individual grades (i.e. a nested for loop) For your demo, calculate the GPA to 2 decimal places for these two course combinations First Case 6 units of A 6 units of B 3 units of C Second Case 4 units of A 6 units of B 5 units of C Can I have the code in Python and the output
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#python3 code
#please refer to the screenshots and take care of indentations

n = 2
gmap = { 'A': 4, 'B': 3, 'C': 2, 'D': 1 }

for i in range(0,n):
name = input("Enter the student name: ")
s = 0
total_units = 0
for j in range(0,3):
g = input("Enter a grade: ")
units = int(input("Enter units of grade: "))
j = j+1
s = s + (gmap[g.upper()]*units)
total_units = total_units + units
gpa = s/total_units
print("The GPA for", name, "is ",end="")
print("%.2f" %gpa)
i = i + 1


Terminal (100%) ,) 12:32 PM ubuntu En new.c Skewness.java stats.cpp new.py new.cpp 1 #python3 code #please refer to the scree

Add a comment
Know the answer?
Add Answer to:
Can I have the code in Python and the output 2-3-B for GPA You previously calculated...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT