title: Adding entries from python dictionary based on key
body: <p>If I have a Python dictionary such as </p>
  
  <pre><code>my_dict = {1:4, 2: 9, 3: 17, 4: 27, 5: 51, 6: 129, 7: 285, 8: 533}
  </code></pre>
  
  <p>how can I iterate through it to produce a count based on keys in the following way: </p>
  
  <p>If my key is smallest i.e. 1, then return 4/sum(values) [I know how to compute this].</p>
  
  <p>If my key is not smallest, then return sum(values corresponding to previous keys)/sum(values); so for example, for key 2, we would return 4+9/1055.</p>
  
  <p>Thanks for any insights!</p>