title: python: round/format float/string to specific decimal/fraction
body: <p>I've found many posts regarding rounding in python, but from my understanding none so far solves my problem.</p>
  
  <p>Two solutions I'm looking for:</p>
  
  <ul>
  <li><p>Round closest: float/string numbers which need to be rounded differently depending on their size.</p></li>
  <li><p>Round down: float/string numbers which need to be rounded <em>down</em> differently depending on their size.</p></li>
  <li><p>Round up: float/string numbers which need to be rounded <em>up</em> differently depending on their size.</p></li>
  </ul>
  
  <p>Example:</p>
  
  <ul>
  <li>+500: 0 decimals (whole numbers) (e.g., Closest: 500.5 -> 501; Down: 500.99 -> 500; Up: 500.01 -> 501)</li>
  <li>+100: 1 decimals (fraction: 0.2) (e.g., Closest: 100.29 -> 100.2; Down: 100.39 -> 100.2; Up: 100.21 -> 100.4). So, the value must end with .0, .2, .4, .6 or .8</li>
  <li>+5: 2 decimals (fraction: 0.01) (e.g., Closest: 5.019 -> 5.02; Down: 5.019 -> 5.01; Up: 5.011 -> 5.02). So, the value must end with .x0, .x1, .x2, .x3, .x4, .x5, .x6, .x7, .x8 or .x9</li>
  </ul>
  
  <p>The resulting variable should be a string.</p>
  
  <p>The neat thing I'm, looking for is a function in which i can pass <em>number of decimals</em> and <em>fraction</em></p>