09-17

  1. (overlap) Given two lists of numbers, produce a sorted list of elements common to both of them.

     overlap [10, 20, 17, 30, 15, 18] [18, 30, 5, 17, 21, 90] == [17, 18, 30]
    
  2. Turn the following table into a dictionary called q2:

Combo Effectiveness
(‘Fire’,‘Fire’) 0.5
(‘Fire’,‘Water’) 0.5
(‘Fire’,‘Grass’) 2.0
(‘Grass’,‘Fire’) 0.5
(‘Ground’,‘Fly’) 0.0
  1. The rules changed, fire types have normal effectiveness against each other. Remove the ('Fire','Fire') entry from the q2 table.

  2. Use items() to print the table using the data from q2.

  3. Make a list of 8 foods. Use enumerate to print out a the foods in order with one more “.” in front of each food. Small example output:

     apple
     .orange
     ..banana
     ...grape
     ....pineapple
    
  4. (countWords) Write a function that counts the occurences of each word in the input string. It produces a dictionary where the keys are the words and the values are the counts.

  5. (sort2) Given a list of ordered pairs (x,y), sort them in descending order based on the second coordinate (y).

Problems

Everyone does the first one. If you want to skip the questions above, do the second one.