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 problem, 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.

Answers

Answer 1

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)


Related Questions

Suppose a byte-addressable computer using set-associative cache has 2 16 bytes of main memory and a cache size of 32 blocks and each cache block contains 8 bytes. a) If this cache is 2-way set associative, what is the format of a memory address as seen by the cache; that is, what are the size of the tag, set, and offset fields

Answers

Answer:

Following are the responses to these question:

Explanation:

The cache size is 2n words whenever the address bit number is n then So, because cache size is 216 words, its number of address bits required for that  cache is 16 because the recollection is relational 2, there is 2 type for each set. Its cache has 32 blocks, so overall sets are as follows:

[tex]\text{Total Number of sets raluired}= \frac{\text{Number of blocks}}{Associativity}[/tex]

                                               [tex]=\frac{32}{2}\\\\ =16\\\\= 2^4 \ sets[/tex]

The set bits required also are 4. Therefore.

Every other block has 8 words, 23 words, so the field of the word requires 3 bits.

For both the tag field, the remaining portion bits are essential. The bytes in the tag field are calculated as follows:

Bits number in the field tag =Address Bits Total number-Set bits number number-Number of bits of words

=16-4-3

= 9 bit

The number of bits inside the individual fields is therefore as follows:

Tag field: 8 bits Tag field

Fieldset: 4 bits

Field Word:3 bits

Create a map using the Java map collection. The map should have 4 entries representing students. Each entry should have a unique student ID for the key and a student name for the element value. The map content can be coded in directly, you do not have to allow a user to enter the map data. Your program will display both the key and the value of each element.

Answers

Answer:

In Java:

import java.util.*;  

public class Main{

   public static void main(String[] args) {

       Map<String, String> students = new HashMap<>();

       students.put("STUD1", "Student 1 Name");

       students.put("STUD2", "Student 2 Name");

       students.put("STUD3", "Student 3 Name");

       students.put("STUD4", "Student 4 Name");

       for(Map.Entry m:students.entrySet()){  

           System.out.println(m.getKey()+" - "+m.getValue());    }  

}}

Explanation:

This creates the map named students

       Map<String, String> students = new HashMap<>();

The next four lines populates the map with the ID and name of the 4 students

       students.put("STUD1", "Student 1 Name");

       students.put("STUD2", "Student 2 Name");

       students.put("STUD3", "Student 3 Name");

       students.put("STUD4", "Student 4 Name");

This iterates through the map

       for(Map.Entry m:students.entrySet()){  

This prints the details of each student

           System.out.println(m.getKey()+" - "+m.getValue());    }  

Log onto the Internet and use a search engine to find three Web sites that can be models for the new site. (At least one should sell sporting goods.) For each site you selected, list the URLs in your document. Tell why you chose them. Navigate to the three sites you choose and take notes about at least three things you like and don’t like about the sites.

Answers

Please see the following file for your required answer, thank you.

Other Questions
What is the value of x? PLS SOMEONE HELP ME QUICKLY What agreement from the end of WW1 placed huge financial burdens upon German as punishment for causing the war?The Munich Pact orThe Treaty of Versailles (pronounced "Vair-Si") The base of the triangular pyramid shown is an equilateral triangle with sides measuring 6 yards and a height of 5.2 yards. Each lateral face is congruent and has a height of 8 yards. The net of a triangular pyramid. What is the surface area of the pyramid? 15.6 square yards 72 square yards 87.6 square yards 144 square yards Religious, norms and values ishelping to increase population." Justifythe statement. HELP ME IF YOU LOVE JESUSwhy does mr pirzada feel increasingly anxious about being away from his homeland? (list several reasons) which of the following is the equivalent to the radical expression below when x> 0 square foot 12x^3 + Square root 6x At the beginning of school you set-up a 4 digit pin to get into your My Payments Plusaccount, however you have not used your account since you set it up and forgot thenumber. You remember that the first number was a 4 and the second number waseither a 5, 6, or 7. You had no idea what the last two numbers were. How manydifferent combinations are possible?900 combinations200 combinations300 combinations1200 combinations how do i find the diameter of a circle with only knowing the area? Define general banking services offered by financial institutions Line GH passes through points (-6,-30) and (4,-5) . What is the linear equation for line GH? The dot plot shows the number of miles Zac ran each day.Distance Ran Each Day00.511.53.544.552 2.5 3Number of MilesThe number of days displayed in the dot plot isThe maximum distance that Zac ran on any one day ismiles. What are some characteristics freelance journalists should develop to be successful? What is (x+1) (x+2) in standard form? The given data set shows the distance traveled, in miles, by customers to a bookstore event to meet their favorite author.40, 35, 44, 90, 23, 25, 28, 35Which data value is considered an outlier? PLEASE HELP ASAP!!! thx!Part 1: Which process does arrow A represent?Part 2: Which type of energy transformation does arrow A represent?Part 3: Justify why this process is a recycling of carbon in the carbon cycle.Use complete sentences to explain your answer. (10 points)(LOOK AT THE PIC BELOW) Which term describes the complete set of processes carried out by an organism in order to sustain life?v refers to the set of chemical processes carried out by an organism in order to sustain life. in Digestion is a form of activity. How are cellular respiration and photosynthesis related?O A. They both use light energy to produce chemical energy.O B. They both use ATP energy to produce radiant energy.C. All of their chemical products are gases found in the atmosphere.O D. The chemical products of one are the reactants of the other. help me pls or im going to fail Coronado was known for the following.Your answer:Mapping the American Southwest.Sailing and mapping the Gulf of Mexico.Conquering the Aztecs.Returning to Mexico City in disgrace for failing to locate gold on his exploration.A and D.