1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
storchak [24]
3 years ago
12

As of Spring 2020, in otder to get into the CS major, you must have a 3.0 GPA or better in cs120, cs210, and cs245. In this prob

lem, you should write one function named get_gpa, which will calculate this GPA. This function should have one parameter, which will be a dictionary of grades in computer science courses. You can assume that the dictionary will always have the keys 'cs120', 'cs210', and 'cs245', but it also might contain some names of other courses too. The values associated with each key will be a float representeing the GPA-style grade for that class. For instance, the parameter dictionary might look like: {'cs120':4.0 'cs245':3.0, 'cs210':2.0}. Some examples:
get_gpa({'cs110': 4.0, 'cs245':3.0, 'cs335':4.0, 'cs120':3.0, 'cs210':3.0}) should return 3.0.
get_gpa({'cs110': 4.0, 'cs120':3.0, 'cs245':2.0, 'cs210':1.0}) should return 2.0.
get_gpa({'cs245':4.0, 'cs120':3.0, 'cs245':2.0}) should return 3.0.

Make sure to include only the one function in your file.
Computers and Technology
1 answer:
andrew-mc [135]3 years ago
3 0

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)

You might be interested in
To prevent rust from forming, a light coating of_____should be applied to all machined surfaces
Fantom [35]
What is that I never heard of that before
4 0
3 years ago
Which are resources that a programmer might use? Select all that apply.
Hoochie [10]

Answer:

online help and user forums iam not sure of this amswer maybe

5 0
3 years ago
Read 2 more answers
Who have a ps4 ?<br> Who have 2k20? <br> Are you good a 2k20 ? <br> Add me on Ps4 eoKyriie
Lena [83]

Answer:

lol i would but i have an Xbox...

Explanation:

4 0
3 years ago
Read 2 more answers
Organisms that reproduce sexually​
weqwewe [10]

Sex glad is responsible

3 0
3 years ago
What statement is accurate in regards to
lorasvet [3.4K]

The statement that is accurate in regards to sharing workbooks is that You must add the feature to the Quick Access Toolbar

<h3>What does a shared workbook implies?</h3>

The term connote the act of sharing an Excel file. Here, a person can give other users any form of access to the same document.

Sharing workbook is one that allow people to make any kinds of edits at the same time, which saves a person the trouble of keeping track of different versions.

Learn more about workbooks from

brainly.com/question/5450162

7 0
1 year ago
Other questions:
  • Write a program that prints the number 1 through 10 using a while loop
    6·1 answer
  • What would happen if a pc that contains a power supply that does not automatically adjust for input voltage is set to 230 volts
    13·1 answer
  • A typical analog cell phone has a frequency of 850 mhz; a digital phone a frequency of 1950 mhz. compared to the signal from an
    7·1 answer
  • Can you tell me what is rast
    5·1 answer
  • What are the ASE special certifications?
    14·2 answers
  • Which of the following would be useful to understand if you wanted to build a web page
    15·1 answer
  • Does this mechanism increase or decrease speed? Why?
    9·1 answer
  • Debug the recursive reverseString method, which is intended to return the input String str reversed (i.e. the same characters bu
    13·1 answer
  • Difference between electrical and electronic devices
    15·2 answers
  • Which of the following is an example of two-factor authentication?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!