Welcome to Westonci.ca, the ultimate question and answer platform. Get expert answers to your questions quickly and accurately. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform. Explore comprehensive solutions to your questions from a wide range of professionals on our user-friendly platform.
Sagot :
Answer:
The function is as follows:
def get_gpa(mydict):
gpa = 0
kount = 0
for course_code, gp in mydict.items():
if course_code == 'cs120' or course_code == 'cs210' or course_code == 'cs245':
gpa += float(gp)
kount+=1
return (gpa/kount)
Explanation:
This defines the function
def get_gpa(mydict):
This initializes gpa to 0
gpa = 0
This initializes kount to 0
kount = 0
This iterates through the courses
for course_code, gp in mydict.items():
If course code is cs120 or cs210 or cs245
if course_code == 'cs120' or course_code == 'cs210' or course_code == 'cs245':
The gpa is added
gpa += float(gp)
And the number of courses is increased by 1
kount+=1
This returns the gpa
return (gpa/kount)
Thanks for using our service. We aim to provide the most accurate answers for all your queries. Visit us again for more insights. Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. Stay curious and keep coming back to Westonci.ca for answers to all your burning questions.